diff options
author | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2020-05-05 12:25:58 +0200 |
---|---|---|
committer | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2020-05-20 12:33:37 +0200 |
commit | 7b6d15cdf271772695d28bf48f1f41a29dc29e28 (patch) | |
tree | d4b86c7119d3fe231c6025da392933e0b8147c73 /tests/auto/quick | |
parent | 1fa77712fb241e9c87bf97263df57a5f6f905702 (diff) |
Fix path validation in FilePickerController::accepted()
In some cases QUrl::toLocalFile() does wrong path conversion on
Windows. Therefore we have to convert the file URL to absolute path
in another way and use FilePath::IsAbsolute() for validating that.
Also stabilize WebEngineViewSingleFileUpload tests. They didn't wait
for html title change when the expected value was the same as the
default title.
Change-Id: Ica7798a299f9b28657afeeccccfba3fdecc515e2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qmltests2/data/tst_filePicker.qml | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/tests/auto/quick/qmltests2/data/tst_filePicker.qml b/tests/auto/quick/qmltests2/data/tst_filePicker.qml index ffd7ef87b..ab30d9e82 100644 --- a/tests/auto/quick/qmltests2/data/tst_filePicker.qml +++ b/tests/auto/quick/qmltests2/data/tst_filePicker.qml @@ -36,6 +36,7 @@ TestWebEngineView { id: webEngineView width: 400 height: 300 + property var titleChanges: [] function driveLetter() { if (Qt.platform.os !== "windows") @@ -54,6 +55,8 @@ TestWebEngineView { signalName: "renderProcessTerminated" } + onTitleChanged: { titleChanges.push(webEngineView.title) } + TestCase { name: "WebEngineViewSingleFileUpload" when: windowShown @@ -65,6 +68,7 @@ TestWebEngineView { FilePickerParams.nameFilters = [] titleSpy.clear() terminationSpy.clear() + titleChanges = [] } function cleanup() { @@ -80,14 +84,14 @@ TestWebEngineView { function test_acceptSingleFileSelection_data() { return [ + { tag: "test.txt", input: "test.txt", expected: "Failed to Upload" }, { tag: driveLetter() + "/test.txt", input: driveLetter() + "/test.txt", expected: "test.txt" }, - { tag: driveLetter() + "test.txt", input: driveLetter() + "test.txt", expected: "Failed to Upload" }, { tag: driveLetter() + "/tést.txt", input: driveLetter() + "/tést.txt", expected: "tést.txt" }, { tag: driveLetter() + "/t%65st.txt", input: driveLetter() + "/t%65st.txt", expected: "t%65st.txt" }, { tag: "file:///" + driveLetter() + "test.txt", input: "file:///" + driveLetter() + "test.txt", expected: "test.txt" }, { tag: "file:///" + driveLetter() + "tést.txt", input: "file:///" + driveLetter() + "tést.txt", expected: "tést.txt" }, - { tag: "file:///" + driveLetter() + "t%65st.txt", input: "file:///" + driveLetter() + "t%65st.txt", expected: "test.txt" }, - { tag: "file://" + driveLetter() + "test.txt", input: "file://" + driveLetter() + "test.txt", expected: "test.txt" }, + { tag: "file:///" + driveLetter() + "t%65st.txt", input: "file:///" + driveLetter() + "t%65st.txt", expected: "t%65st.txt" }, + { tag: "file://" + driveLetter() + "test.txt", input: "file://" + driveLetter() + "test.txt", expected: "Failed to Upload" }, { tag: "file:/" + driveLetter() + "test.txt", input: "file:/" + driveLetter() + "test.txt", expected: "test.txt"}, { tag: "file:test//test.txt", input: "file:test//test.txt", expected: "Failed to Upload" }, { tag: "http://test.txt", input: "http://test.txt", expected: "Failed to Upload" }, @@ -107,7 +111,10 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryCompare(FilePickerParams, "filePickerOpened", true); - tryCompare(webEngineView, "title", row.expected); + webEngineView.url = Qt.resolvedUrl("about:blank"); + verify(webEngineView.waitForLoadSucceeded()); + tryCompare(webEngineView, "title", "about:blank"); + compare(titleChanges[titleChanges.length-2], row.expected); // Custom dialog @@ -125,7 +132,10 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryVerify(function() { return finished; }); - tryCompare(webEngineView, "title", row.expected); + webEngineView.url = Qt.resolvedUrl("about:blank"); + verify(webEngineView.waitForLoadSucceeded()); + tryCompare(webEngineView, "title", "about:blank"); + compare(titleChanges[titleChanges.length-2], row.expected); webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); } @@ -212,19 +222,19 @@ TestWebEngineView { { tag: "C:/test.txt", input: "C:/test.txt", expected: "test.txt"}, { tag: "C:\\test.txt", input: "C:\\test.txt", expected: "test.txt"}, { tag: "C:\\Documents and Settings\\test\\test.txt", input: "C:\\Documents and Settings\\test\\test.txt", expected: "test.txt"}, - { tag: "\\\\applib\\products\\a%2Db\\ abc%5F9\\t.est\\test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"}, - { tag: "file://applib/products/a%2Db/ abc%5F9/t.est/test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"}, + { tag: "\\\\applib\\products\\a%2Db\\ abc%5F9\\t.est\\test.txt", input: "\\\\applib\\products\\a%2Db\\ abc%5F9\\t.est\\test.txt", expected: "test.txt"}, + { tag: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"}, { tag: "file://applib/products/a-b/abc_1/t.est/test.txt", input: "file://applib/products/a-b/abc_1/t.est/test.txt", expected: "test.txt"}, { tag: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", input: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", expected: "test.txt"}, - { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "Failed to Upload"}, - { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "Failed to Upload"}, + { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "test.tx"}, + { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "test.tx"}, { tag: "file://C:/test.txt", input: "file://C:/test.txt", expected: "Failed to Upload"}, { tag: "file:///C:test.txt", input: "file:///C:test.txt", expected: "Failed to Upload"}, { tag: "file:///C:/test.txt", input: "file:///C:/test.txt", expected: "test.txt"}, { tag: "file:///C:\\test.txt", input: "file:///C:\\test.txt", expected: "test.txt"}, { tag: "file:\\//C:/test.txt", input: "file:\\//C:/test.txt", expected: "test.txt"}, { tag: "file:\\\\/C:\\test.txt", input: "file:\\\\/C:\\test.txt", expected: "test.txt"}, - { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "Failed to Upload"}, + { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "test.tx"}, ]; } @@ -241,7 +251,10 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryCompare(FilePickerParams, "filePickerOpened", true); - tryCompare(webEngineView, "title", row.expected); + webEngineView.url = Qt.resolvedUrl("about:blank"); + verify(webEngineView.waitForLoadSucceeded()); + tryCompare(webEngineView, "title", "about:blank"); + compare(titleChanges[titleChanges.length-2], row.expected); // Custom dialog @@ -259,7 +272,10 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryVerify(function() { return finished; }); - tryCompare(webEngineView, "title", row.expected); + webEngineView.url = Qt.resolvedUrl("about:blank"); + verify(webEngineView.waitForLoadSucceeded()); + tryCompare(webEngineView, "title", "about:blank"); + compare(titleChanges[titleChanges.length-2], row.expected); webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); } |