summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests')
-rw-r--r--tests/auto/quick/qmltests/BLACKLIST9
-rw-r--r--tests/auto/quick/qmltests/data/multifileupload.html2
-rw-r--r--tests/auto/quick/qmltests/data/singlefileupload.html2
-rw-r--r--tests/auto/quick/qmltests/data/tst_download.qml20
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml106
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml4
-rw-r--r--tests/auto/quick/qmltests/data/tst_newViewRequest.qml5
-rw-r--r--tests/auto/quick/qmltests/data/tst_notification.qml122
-rw-r--r--tests/auto/quick/qmltests/data/tst_profile.qml66
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro2
10 files changed, 312 insertions, 26 deletions
diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST
index 083c15984..46bc65923 100644
--- a/tests/auto/quick/qmltests/BLACKLIST
+++ b/tests/auto/quick/qmltests/BLACKLIST
@@ -1,11 +1,2 @@
-[WebEngineViewSingleFileUpload::test_acceptDirectory]
-*
-
-[WebEngineViewSingleFileUpload::test_acceptMultipleFilesSelection]
-*
-
-[WebEngineViewSingleFileUpload::test_acceptSingleFileSelection]
-*
-
[WebEngineViewSource::test_viewSourceURL]
*
diff --git a/tests/auto/quick/qmltests/data/multifileupload.html b/tests/auto/quick/qmltests/data/multifileupload.html
index 1f788a377..d41ea15c0 100644
--- a/tests/auto/quick/qmltests/data/multifileupload.html
+++ b/tests/auto/quick/qmltests/data/multifileupload.html
@@ -1,7 +1,7 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
-<title> Mutli-file Upload </title>
+<title> Failed to Upload </title>
<script src = "./titleupdate.js">
</script>
</head>
diff --git a/tests/auto/quick/qmltests/data/singlefileupload.html b/tests/auto/quick/qmltests/data/singlefileupload.html
index 6cfef7ade..ac91c2c0d 100644
--- a/tests/auto/quick/qmltests/data/singlefileupload.html
+++ b/tests/auto/quick/qmltests/data/singlefileupload.html
@@ -1,7 +1,7 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
-<title> Single File Upload </title>
+<title> Failed to Upload </title>
<script src = "./titleupdate.js">
</script>
</head>
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml
index 019ebd9dc..5eb704cce 100644
--- a/tests/auto/quick/qmltests/data/tst_download.qml
+++ b/tests/auto/quick/qmltests/data/tst_download.qml
@@ -28,7 +28,8 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.5
+import QtWebEngine 1.9
+import Qt.labs.platform 1.0
TestWebEngineView {
id: webEngineView
@@ -42,6 +43,12 @@ TestWebEngineView {
property var downloadState: []
property var downloadInterruptReason: null
+ function urlToPath(url) {
+ var path = url.toString()
+ path = path.replace(/^(file:\/{2})/,"")
+ return path
+ }
+
SignalSpy {
id: downLoadRequestedSpy
target: testDownloadProfile
@@ -135,5 +142,16 @@ TestWebEngineView {
tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadCancelled)
tryCompare(webEngineView, "downloadInterruptReason", WebEngineDownloadItem.UserCanceled)
}
+
+ function test_downloadLocation() {
+ var tmpPath = urlToPath(StandardPaths.writableLocation(StandardPaths.TempLocation));
+ var downloadPath = urlToPath(StandardPaths.writableLocation(StandardPaths.DownloadLocation));
+
+ testDownloadProfile.downloadPath = tmpPath;
+ compare(testDownloadProfile.downloadPath, tmpPath);
+
+ testDownloadProfile.downloadPath = downloadPath;
+ compare(testDownloadProfile.downloadPath, downloadPath);
+ }
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml
index 655789bb3..2f813b966 100644
--- a/tests/auto/quick/qmltests/data/tst_filePicker.qml
+++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml
@@ -70,16 +70,61 @@ TestWebEngineView {
webEngineView.waitForLoadSucceeded()
}
- function test_acceptSingleFileSelection() {
- webEngineView.url = Qt.resolvedUrl("singlefileupload.html")
- verify(webEngineView.waitForLoadSucceeded())
+ function test_acceptSingleFileSelection_data() {
+ return [
+ { tag: "/test.txt)", input: "/test.txt", passDefaultDialog: false, passCustomDialog: true },
+ { tag: "/tést.txt", input: "/tést.txt", passDefaultDialog: false, passCustomDialog: true },
+ { tag: "file:///test.txt", input: "file:///test.txt", passDefaultDialog: true, passCustomDialog: false },
+ { tag: "file:///tést.txt", input: "file:///tést.txt", passDefaultDialog: true, passCustomDialog: false },
+ { tag: "file:///t%C3%A9st.txt", input: "file:///t%C3%A9st.txt", passDefaultDialog: true, passCustomDialog: false },
+ { tag: "file://test.txt", input: "file://test.txt", passDefaultDialog: false, passCustomDialog: false },
+ { tag: "file:/test.txt", input: "file:/test.txt", passDefaultDialog: true, passCustomDialog: false },
+ { tag: "file:test//test.txt", input: "file:test//test.txt", passDefaultDialog: false, passCustomDialog: false },
+ { tag: "http://test.txt", input: "http://test.txt", passDefaultDialog: false, passCustomDialog: false },
+ { tag: "qrc:/test.txt", input: "qrc:/test.txt", passDefaultDialog: false, passCustomDialog: false },
+ ];
+ }
- FilePickerParams.selectFiles = true
- FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html"))
+ function test_acceptSingleFileSelection(row) {
+ var expectedFileName;
- keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
- tryCompare(FilePickerParams, "filePickerOpened", true)
- tryCompare(webEngineView, "title", "test1.html")
+ // Default dialog (expects URL).
+ expectedFileName = "Failed to Upload";
+ if (row.passDefaultDialog)
+ expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1);
+
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl.push(row.input);
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryCompare(webEngineView, "title", decodeURIComponent(expectedFileName));
+
+
+ // Custom dialog (expects absolute path).
+ var finished = false;
+
+ expectedFileName = "Failed to Upload";
+ if (row.passCustomDialog)
+ expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1);
+
+ function acceptedFileHandler(request) {
+ request.accepted = true;
+ request.dialogAccept(row.input);
+ finished = true;
+ }
+
+ webEngineView.fileDialogRequested.connect(acceptedFileHandler);
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryVerify(function() { return finished; });
+ tryCompare(webEngineView, "title", expectedFileName);
+ webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
}
function test_acceptMultipleFilesSelection() {
@@ -102,9 +147,10 @@ TestWebEngineView {
FilePickerParams.selectFiles = true
FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data"))
- keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ keyClick(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
tryCompare(FilePickerParams, "filePickerOpened", true)
- tryCompare(webEngineView, "title", "data")
+ // Check that the title is a file list (eg. "test1.html,test2.html")
+ tryVerify(function() { return webEngineView.title.match("^([^,]+,)+[^,]+$"); })
}
function test_reject() {
@@ -116,5 +162,45 @@ TestWebEngineView {
wait(100)
compare(titleSpy.count, 0)
}
+
+ function test_acceptMultipleFilesWithCustomDialog_data() {
+ return [
+ { tag: "path", input: ["/test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "Failed to Upload", expectedValueForCustomDialog: "test1.txt,test2.txt" },
+ { tag: "file", input: ["file:///test1.txt", "file:///test2.txt"], expectedValueForDefaultDialog: "test1.txt,test2.txt", expectedValueForCustomDialog: "Failed to Upload" },
+ { tag: "mixed", input: ["file:///test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "test1.txt", expectedValueForCustomDialog: "test2.txt" },
+ ];
+ }
+
+ function test_acceptMultipleFilesWithCustomDialog(row) {
+ // Default dialog (expects URL).
+ webEngineView.url = Qt.resolvedUrl("multifileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl = row.input;
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryCompare(webEngineView, "title", row.expectedValueForDefaultDialog);
+
+
+ // Custom dialog (expects absolute path).
+ var finished = false;
+
+ function acceptedFileHandler(request) {
+ request.accepted = true;
+ request.dialogAccept(row.input);
+ finished = true;
+ }
+
+ webEngineView.fileDialogRequested.connect(acceptedFileHandler);
+ webEngineView.url = Qt.resolvedUrl("multifileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryVerify(function() { return finished; });
+ tryCompare(webEngineView, "title", row.expectedValueForCustomDialog);
+ webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
+ }
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index dfcfd586f..1ec574fae 100644
--- a/tests/auto/quick/qmltests/data/tst_findText.qml
+++ b/tests/auto/quick/qmltests/data/tst_findText.qml
@@ -116,7 +116,7 @@ TestWebEngineView {
webEngineView.clear()
webEngineView.findText("bla", findFlags, webEngineView.findTextCallback)
- tryCompare(webEngineView, "matchCount", 100)
+ tryCompare(webEngineView, "matchCount", 100, 20000)
verify(!findFailed)
}
@@ -172,7 +172,7 @@ TestWebEngineView {
webEngineView.clear()
webEngineView.findText("hello", findFlags, webEngineView.findTextCallback)
- tryCompare(webEngineView, "matchCount", 0)
+ tryCompare(webEngineView, "matchCount", 0, 20000)
verify(findFailed)
runJavaScript("document.body.innerHTML = 'blahellobla'");
diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
index 4becbb620..a671c2ec7 100644
--- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
@@ -98,7 +98,8 @@ TestWebEngineView {
verify(dialog.webEngineView.waitForLoadSucceeded());
compare(dialog.webEngineView.url, "");
- compare(newViewRequest.requestedUrl, 'about:blank');
+ // https://chromium-review.googlesource.com/c/chromium/src/+/1300395
+ compare(newViewRequest.requestedUrl, 'about:blank#blocked');
newViewRequestedSpy.clear();
dialog.destroy();
@@ -129,8 +130,8 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
verifyElementHasFocus("popupButton");
keyPress(Qt.Key_Enter);
- compare(newViewRequest.requestedUrl, url);
tryCompare(newViewRequestedSpy, "count", 1);
+ compare(newViewRequest.requestedUrl, url);
compare(newViewRequest.destination, WebEngineView.NewViewInDialog);
verify(newViewRequest.userInitiated);
diff --git a/tests/auto/quick/qmltests/data/tst_notification.qml b/tests/auto/quick/qmltests/data/tst_notification.qml
new file mode 100644
index 000000000..773bf4a8e
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_notification.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 2.2
+import QtTest 1.0
+import QtWebEngine 1.9
+
+TestWebEngineView {
+ id: view
+ width: 320
+ height: 320
+
+ property bool permissionRequested: false
+ property bool grantPermission: false
+ property url securityOrigin: ''
+
+ signal consoleMessage(string message)
+
+ SignalSpy {
+ id: spyRequest
+ target: view
+ signalName: 'featurePermissionRequested'
+ }
+
+ onFeaturePermissionRequested: {
+ if (feature === WebEngineView.Notifications) {
+ view.permissionRequested = true
+ view.securityOrigin = securityOrigin
+ view.grantFeaturePermission(securityOrigin, feature, grantPermission)
+ }
+ }
+
+ TestCase {
+ name: 'WebEngineNotification'
+ when: windowShown
+
+ function resolverUrl(html) {
+ return Qt.resolvedUrl('../../../shared/data/' + html)
+ }
+
+ function init() {
+ permissionRequested = false
+ spyRequest.clear()
+ }
+
+ function test_request_data() {
+ return [
+ { tag: 'grant', grant: true, permission: 'granted' },
+ { tag: 'deny', grant: false, permission: 'denied' },
+ ]
+ }
+
+ function test_request(data) {
+ grantPermission = data.grant
+
+ view.url = resolverUrl('notification.html')
+ verify(view.waitForLoadSucceeded())
+
+ view.runJavaScript('resetPermission()')
+ let result = {}
+
+ view.runJavaScript('getPermission()', function (permission) { result.permission = permission })
+ tryCompare(result, 'permission', 'default')
+
+ view.runJavaScript('requestPermission()')
+ spyRequest.wait()
+ verify(permissionRequested)
+ compare(spyRequest.count, 1)
+
+ view.runJavaScript('getPermission()', function (permission) { result.permission = permission })
+ tryCompare(result, 'permission', data.permission)
+ }
+
+ function test_notification() {
+ grantPermission = true
+
+ view.url = resolverUrl('notification.html')
+ view.waitForLoadSucceeded()
+
+ view.runJavaScript('requestPermission()')
+ spyRequest.wait()
+ verify(permissionRequested)
+
+ let title = 'Title', message = 'Message', notification = null
+ view.profile.presentNotification.connect(function (n) { notification = n })
+
+ view.runJavaScript('sendNotification("' + title + '", "' + message + '")')
+ tryVerify(function () { return notification !== null })
+ compare(notification.title, title)
+ compare(notification.message, message)
+ compare(notification.direction, Qt.RightToLeft)
+ compare(notification.origin, securityOrigin)
+ compare(notification.tag, 'tst')
+ compare(notification.language, 'de')
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_profile.qml b/tests/auto/quick/qmltests/data/tst_profile.qml
new file mode 100644
index 000000000..ee7fa4e99
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_profile.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 2.0
+import QtTest 1.0
+import QtWebEngine 1.9
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+
+
+ WebEngineProfile {
+ id: profile1
+ }
+ WebEngineProfile {
+ id: profile2
+ }
+ property bool profile1UsedForGlobalCertificateVerification: profile1.useForGlobalCertificateVerification
+
+ TestCase {
+ name: "WebEngineProfile"
+
+ function test_useForGlobalCertificateVerification() {
+ verify(!profile1.useForGlobalCertificateVerification);
+ verify(!profile2.useForGlobalCertificateVerification);
+ verify(!webEngineView.profile1UsedForGlobalCertificateVerification);
+
+ profile1.useForGlobalCertificateVerification = true;
+ verify(profile1.useForGlobalCertificateVerification);
+ verify(!profile2.useForGlobalCertificateVerification);
+ verify(webEngineView.profile1UsedForGlobalCertificateVerification);
+
+ profile2.useForGlobalCertificateVerification = true;
+ verify(!webEngineView.profile1UsedForGlobalCertificateVerification);
+ verify(!profile1.useForGlobalCertificateVerification);
+ verify(profile2.useForGlobalCertificateVerification);
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index a2b05e091..00e884e11 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -67,6 +67,8 @@ OTHER_FILES += \
$$PWD/data/tst_navigationHistory.qml \
$$PWD/data/tst_navigationRequested.qml \
$$PWD/data/tst_newViewRequest.qml \
+ $$PWD/data/tst_notification.qml \
+ $$PWD/data/tst_profile.qml \
$$PWD/data/tst_properties.qml \
$$PWD/data/tst_runJavaScript.qml \
$$PWD/data/tst_scrollPosition.qml \