diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-09 15:22:24 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-09 15:22:24 +0200 |
commit | 0eac492b5c66b1774118c387dd527ad419e51be7 (patch) | |
tree | 37324fdefd615e433dd65073390d7b9996d660d3 /tests/auto/quick | |
parent | 5d6086d1b97461b35c143839a8a6ba1b990bb87c (diff) | |
parent | 99d46a8a918dee7323bc3d4f1624c47c097f9a3a (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I495adfcbb010ac29dc64e051c030a92d27859ca6
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/dialogs/WebView.qml | 2 | ||||
-rw-r--r-- | tests/auto/quick/dialogs/tst_dialogs.cpp | 3 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/BLACKLIST | 9 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/multifileupload.html | 2 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/singlefileupload.html | 2 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_filePicker.qml | 106 |
6 files changed, 102 insertions, 22 deletions
diff --git a/tests/auto/quick/dialogs/WebView.qml b/tests/auto/quick/dialogs/WebView.qml index 6509071b8..4f8b7a0ce 100644 --- a/tests/auto/quick/dialogs/WebView.qml +++ b/tests/auto/quick/dialogs/WebView.qml @@ -59,6 +59,8 @@ Window { onLoadingChanged: function(reqeust) { if (reqeust.status === WebEngineView.LoadSucceededStatus) { handler.ready = true + } else { + console.log("Wooohooo loading page from qrc failed !") } } diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp index 26a0fe034..eee6b2bb6 100644 --- a/tests/auto/quick/dialogs/tst_dialogs.cpp +++ b/tests/auto/quick/dialogs/tst_dialogs.cpp @@ -116,7 +116,7 @@ void tst_Dialogs::colorDialogRequested() void tst_Dialogs::contextMenuRequested() { m_listner->load(QUrl("qrc:/index.html")); - QTRY_VERIFY(m_listner->ready()); + QTRY_COMPARE_WITH_TIMEOUT(m_listner->ready(), true, 20000); QSignalSpy dialogSpy(m_listner, &TestHandler::requestChanged); QTest::mouseClick(m_widnow, Qt::RightButton); QTRY_COMPARE(dialogSpy.count(), 1); @@ -226,6 +226,7 @@ void tst_Dialogs::javaScriptDialogRequested() QCOMPARE(dialog->type(), type); QCOMPARE(dialog->message(), message); QCOMPARE(dialog->defaultText(), defaultText); + QTRY_VERIFY(m_listner->ready()); // make sure javascript executes no longer } #include "tst_dialogs.moc" diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST index dfafbaea4..957911c3b 100644 --- a/tests/auto/quick/qmltests/BLACKLIST +++ b/tests/auto/quick/qmltests/BLACKLIST @@ -4,15 +4,6 @@ osx [WebViewGeopermission::test_geoPermissionRequest] osx -[WebEngineViewSingleFileUpload::test_acceptDirectory] -* - -[WebEngineViewSingleFileUpload::test_acceptMultipleFilesSelection] -* - -[WebEngineViewSingleFileUpload::test_acceptSingleFileSelection] -* - [WebViewFindText::test_findTextInterruptedByLoad] * 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_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); + } } } |