summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data/tst_filePicker.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests/data/tst_filePicker.qml')
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml106
1 files changed, 96 insertions, 10 deletions
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);
+ }
}
}