diff options
Diffstat (limited to 'tests/auto/quick/qmltests/data')
-rw-r--r-- | tests/auto/quick/qmltests/data/accepttypes.html | 21 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/test4.html | 200 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_download.qml | 106 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_filePicker.qml | 29 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_loadUrl.qml | 2 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_navigationHistory.qml | 7 |
6 files changed, 258 insertions, 107 deletions
diff --git a/tests/auto/quick/qmltests/data/accepttypes.html b/tests/auto/quick/qmltests/data/accepttypes.html new file mode 100644 index 000000000..aff39f96e --- /dev/null +++ b/tests/auto/quick/qmltests/data/accepttypes.html @@ -0,0 +1,21 @@ +<html> +<head> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<title>Default title</title> +</head> + +<body> +<input type="file" name="file" id="upfile" accept=""> + +<script> +window.onload = function() { + document.getElementById("upfile").focus(); +} + +function setAcceptType(acceptType) { + document.getElementById("upfile").accept = acceptType; + document.title = acceptType; +} +</script> +</body> +</html> diff --git a/tests/auto/quick/qmltests/data/test4.html b/tests/auto/quick/qmltests/data/test4.html index afda71bc5..c9b395ee5 100644 --- a/tests/auto/quick/qmltests/data/test4.html +++ b/tests/auto/quick/qmltests/data/test4.html @@ -24,106 +24,106 @@ } </script> <div id="content"> - bla00<br/> - bla01<br/> - bla02<br/> - bla03<br/> - bla04<br/> - bla05<br/> - bla06<br/> - bla07<br/> - bla08<br/> - bla09<br/> - bla10<br/> - bla11<br/> - bla12<br/> - bla13<br/> - bla14<br/> - bla15<br/> - bla16<br/> - bla17<br/> - bla18<br/> - bla19<br/> - bla20<br/> - bla21<br/> - bla22<br/> - bla23<br/> - bla24<br/> - bla25<br/> - bla26<br/> - bla27<br/> - bla28<br/> - bla29<br/> - bla30<br/> - bla31<br/> - bla32<br/> - bla33<br/> - bla34<br/> - bla35<br/> - bla36<br/> - bla37<br/> - bla38<br/> - bla39<br/> - bla40<br/> - bla41<br/> - bla42<br/> - bla43<br/> - bla44<br/> - bla45<br/> - bla46<br/> - bla47<br/> - bla48<br/> - bla49<br/> - bla50<br/> - bla51<br/> - bla52<br/> - bla53<br/> - bla54<br/> - bla55<br/> - bla56<br/> - bla57<br/> - bla58<br/> - bla59<br/> - bla60<br/> - bla61<br/> - bla62<br/> - bla63<br/> - bla64<br/> - bla65<br/> - bla66<br/> - bla67<br/> - bla68<br/> - bla69<br/> - bla70<br/> - bla71<br/> - bla72<br/> - bla73<br/> - bla74<br/> - bla75<br/> - bla76<br/> - bla77<br/> - bla78<br/> - bla79<br/> - bla80<br/> - bla81<br/> - bla82<br/> - bla83<br/> - bla84<br/> - bla85<br/> - bla86<br/> - bla87<br/> - bla88<br/> - bla89<br/> - bla90<br/> - bla91<br/> - bla92<br/> - bla93<br/> - bla94<br/> - bla95<br/> - bla96<br/> - bla97<br/> - bla98<br/> - bla99<br/> + <p>bla00 + <p>bla01 + <p>bla02 + <p>bla03 + <p>bla04 + <p>bla05 + <p>bla06 + <p>bla07 + <p>bla08 + <p>bla09 + <p>bla10 + <p>bla11 + <p>bla12 + <p>bla13 + <p>bla14 + <p>bla15 + <p>bla16 + <p>bla17 + <p>bla18 + <p>bla19 + <p>bla20 + <p>bla21 + <p>bla22 + <p>bla23 + <p>bla24 + <p>bla25 + <p>bla26 + <p>bla27 + <p>bla28 + <p>bla29 + <p>bla30 + <p>bla31 + <p>bla32 + <p>bla33 + <p>bla34 + <p>bla35 + <p>bla36 + <p>bla37 + <p>bla38 + <p>bla39 + <p>bla40 + <p>bla41 + <p>bla42 + <p>bla43 + <p>bla44 + <p>bla45 + <p>bla46 + <p>bla47 + <p>bla48 + <p>bla49 + <p>bla50 + <p>bla51 + <p>bla52 + <p>bla53 + <p>bla54 + <p>bla55 + <p>bla56 + <p>bla57 + <p>bla58 + <p>bla59 + <p>bla60 + <p>bla61 + <p>bla62 + <p>bla63 + <p>bla64 + <p>bla65 + <p>bla66 + <p>bla67 + <p>bla68 + <p>bla69 + <p>bla70 + <p>bla71 + <p>bla72 + <p>bla73 + <p>bla74 + <p>bla75 + <p>bla76 + <p>bla77 + <p>bla78 + <p>bla79 + <p>bla80 + <p>bla81 + <p>bla82 + <p>bla83 + <p>bla84 + <p>bla85 + <p>bla86 + <p>bla87 + <p>bla88 + <p>bla89 + <p>bla90 + <p>bla91 + <p>bla92 + <p>bla93 + <p>bla94 + <p>bla95 + <p>bla96 + <p>bla97 + <p>bla98 + <p>bla99 </div> </body> </html> diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml index e049f3621..1b1750dd8 100644 --- a/tests/auto/quick/qmltests/data/tst_download.qml +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -30,6 +30,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebEngine 1.10 import Qt.labs.platform 1.0 +import Test.util 1.0 TestWebEngineView { id: webEngineView @@ -51,6 +52,9 @@ TestWebEngineView { property int downloadDirectoryChanged: 0 property int downloadFileNameChanged: 0 property int downloadPathChanged: 0 + property bool setDirectoryFirst: false + + TempDir { id: tempDir } function urlToPath(url) { var path = url.toString() @@ -87,7 +91,7 @@ TestWebEngineView { id: testDownloadProfile onDownloadRequested: { - testDownloadProfile.downloadPath = urlToPath(StandardPaths.writableLocation(StandardPaths.TempLocation)) + testDownloadProfile.downloadPath = tempDir.path() downloadState.push(download.state) downloadItemConnections.target = download if (cancelDownload) { @@ -99,8 +103,15 @@ TestWebEngineView { download.path = testDownloadProfile.downloadPath + downloadedSetPath downloadedPath = download.path } else { - download.downloadDirectory = downloadDirectory.length != 0 ? testDownloadProfile.downloadPath + downloadDirectory : testDownloadProfile.downloadPath - download.downloadFileName = downloadFileName.length != 0 ? downloadFileName : "testfile.zip" + if (setDirectoryFirst && downloadDirectory.length != 0) + download.downloadDirectory = testDownloadProfile.downloadPath + downloadDirectory + + if (downloadFileName.length != 0) + download.downloadFileName = downloadFileName + + if (!setDirectoryFirst && downloadDirectory.length != 0) + download.downloadDirectory = testDownloadProfile.downloadPath + downloadDirectory + downloadedPath = download.downloadDirectory + download.downloadFileName } @@ -133,10 +144,12 @@ TestWebEngineView { downloadFileName = "" downloadedPath = "" downloadedSetPath = "" + setDirectoryFirst = false } function test_downloadRequest() { compare(downLoadRequestedSpy.count, 0) + downloadDirectory = "/test_downloadRequest/"; webEngineView.url = Qt.resolvedUrl("download.zip") downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) @@ -148,6 +161,7 @@ TestWebEngineView { function test_totalFileLength() { compare(downLoadRequestedSpy.count, 0) + downloadDirectory = "/test_totalFileLength/"; webEngineView.url = Qt.resolvedUrl("download.zip") downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) @@ -159,6 +173,7 @@ TestWebEngineView { function test_downloadSucceeded() { compare(downLoadRequestedSpy.count, 0) + downloadDirectory = "/test_downloadSucceeded/"; webEngineView.url = Qt.resolvedUrl("download.zip") downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) @@ -196,11 +211,19 @@ TestWebEngineView { compare(testDownloadProfile.downloadPath, downloadPath); } - function test_downloadToDirectoryWithFileName() { + function test_downloadToDirectoryWithFileName_data() { + return [ + { tag: "setDirectoryFirst", setDirectoryFirst: true }, + { tag: "setFileNameFirst", setDirectoryFirst: false }, + ]; + } + + function test_downloadToDirectoryWithFileName(row) { compare(downLoadRequestedSpy.count, 0); compare(downloadDirectoryChanged, 0); compare(downloadFileNameChanged, 0); - downloadDirectory = "/test/"; + setDirectoryFirst = row.setDirectoryFirst; + downloadDirectory = "/test_downloadToDirectoryWithFileName/"; downloadFileName = "test.zip"; webEngineView.url = Qt.resolvedUrl("download.zip"); downLoadRequestedSpy.wait(); @@ -219,11 +242,82 @@ TestWebEngineView { verify(!downloadInterruptReason); } + function test_downloadToDirectoryWithSuggestedFileName() { + // Download file to a custom download directory with suggested file name. + compare(downLoadRequestedSpy.count, 0); + compare(downloadDirectoryChanged, 0); + compare(downloadFileNameChanged, 0); + downloadDirectory = "/test_downloadToDirectoryWithSuggestedFileName/"; + webEngineView.url = Qt.resolvedUrl("download.zip"); + downLoadRequestedSpy.wait(); + compare(downLoadRequestedSpy.count, 1); + compare(downloadUrl, webEngineView.url); + compare(suggestedFileName, "download.zip"); + compare(downloadState[0], WebEngineDownloadItem.DownloadRequested); + tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress); + compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download.zip"); + compare(downloadDirectoryChanged, 1); + compare(downloadFileNameChanged, 0); + compare(downloadPathChanged, 1); + downloadFinishedSpy.wait(); + compare(totalBytes, receivedBytes); + tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted); + verify(!downloadInterruptReason); + + // Download the same file to another directory with suggested file name. + // The downloadFileNameChanged signal should not be emitted. + downLoadRequestedSpy.clear(); + compare(downLoadRequestedSpy.count, 0); + downloadDirectoryChanged = 0; + downloadFileNameChanged = 0; + downloadPathChanged = 0; + downloadDirectory = "/test_downloadToDirectoryWithSuggestedFileName1/"; + webEngineView.url = Qt.resolvedUrl("download.zip"); + downLoadRequestedSpy.wait(); + compare(downLoadRequestedSpy.count, 1); + compare(downloadUrl, webEngineView.url); + compare(suggestedFileName, "download.zip"); + compare(downloadState[0], WebEngineDownloadItem.DownloadRequested); + tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress); + compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download.zip"); + compare(downloadDirectoryChanged, 1); + compare(downloadFileNameChanged, 0); + compare(downloadPathChanged, 1); + downloadFinishedSpy.wait(); + compare(totalBytes, receivedBytes); + tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted); + verify(!downloadInterruptReason); + + // Download same file to same directory second time -> file name should be unified. + // The downloadFileNameChanged signal should be emitted. + downLoadRequestedSpy.clear(); + compare(downLoadRequestedSpy.count, 0); + downloadDirectoryChanged = 0; + downloadFileNameChanged = 0; + downloadPathChanged = 0; + downloadDirectory = "/test_downloadToDirectoryWithSuggestedFileName1/"; + webEngineView.url = Qt.resolvedUrl("download.zip"); + downLoadRequestedSpy.wait(); + compare(downLoadRequestedSpy.count, 1); + compare(downloadUrl, webEngineView.url); + compare(suggestedFileName, "download.zip"); + compare(downloadState[0], WebEngineDownloadItem.DownloadRequested); + tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress); + compare(downloadedPath, testDownloadProfile.downloadPath + downloadDirectory + "download (1).zip"); + compare(downloadDirectoryChanged, 1); + compare(downloadFileNameChanged, 1); + compare(downloadPathChanged, 1); + downloadFinishedSpy.wait(); + compare(totalBytes, receivedBytes); + tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted); + verify(!downloadInterruptReason); +} + function test_downloadWithSetPath() { compare(downLoadRequestedSpy.count, 0); compare(downloadDirectoryChanged, 0); compare(downloadFileNameChanged, 0); - downloadedSetPath = "/test/test.zip"; + downloadedSetPath = "/test_downloadWithSetPath/test.zip"; webEngineView.url = Qt.resolvedUrl("download.zip"); downLoadRequestedSpy.wait(); compare(downLoadRequestedSpy.count, 1); diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml index fad81273c..15eadb2a1 100644 --- a/tests/auto/quick/qmltests/data/tst_filePicker.qml +++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml @@ -61,6 +61,7 @@ TestWebEngineView { FilePickerParams.filePickerOpened = false FilePickerParams.selectFiles = false FilePickerParams.selectedFilesUrl = [] + FilePickerParams.nameFilters = [] titleSpy.clear() terminationSpy.clear() } @@ -260,5 +261,33 @@ TestWebEngineView { tryCompare(webEngineView, "title", row.expected); webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); } + + function test_acceptFileTypes_data() { + return [ + { tag: "CustomSuffix", input: ".pug", expected: ".pug", exactMatch: false}, + { tag: "CustomMime", input: "dog/pug", expected: "Accepted types ()", exactMatch: true}, + { tag: "CustomGlob", input: "dog/*", expected: "Accepted types ()", exactMatch: true}, + { tag: "Invalid", input: "---", expected: undefined, exactMatch: true}, + { tag: "Jpeg", input: "image/jpeg", expected: ".jpeg", exactMatch: false} + ]; + } + + function test_acceptFileTypes(row) { + var expectedFileName; + + webEngineView.url = Qt.resolvedUrl("accepttypes.html"); + verify(webEngineView.waitForLoadSucceeded()); + + webEngineView.runJavaScript("setAcceptType('" + row.input + "');"); + tryCompare(webEngineView, "title", row.input); + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryCompare(FilePickerParams, "filePickerOpened", true); + + if (row.exactMatch) + compare(FilePickerParams.nameFilters[0], row.expected); + else + verify(FilePickerParams.nameFilters[0].includes(row.expected)); + } } } diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml index ec5c965ea..872c46641 100644 --- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml +++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml @@ -230,7 +230,7 @@ TestWebEngineView { compare(loadRequest.activeUrl, aboutBlank); loadRequest = loadRequestArray[2]; compare(loadRequest.status, WebEngineView.LoadStartedStatus); - compare(loadRequest.activeUrl, aboutBlank); + compare(loadRequest.activeUrl, bogusSite); compare(loadRequest.url, "data:text/html;charset=UTF-8,load failed") loadRequest = loadRequestArray[3]; compare(loadRequest.status, WebEngineView.LoadSucceededStatus); diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml index 77664e645..6ed232589 100644 --- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml +++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml @@ -134,6 +134,13 @@ TestWebEngineView { compare(forwardItemsList.count, 1) compare(backItemsList.currentItem.text, Qt.resolvedUrl("test1.html")) compare(forwardItemsList.currentItem.text, Qt.resolvedUrl("javascript.html")) + + webEngineView.navigationHistory.clear() + compare(webEngineView.url, Qt.resolvedUrl("test2.html")) + compare(webEngineView.canGoBack, false) + compare(webEngineView.canGoForward, false) + compare(backItemsList.count, 0) + compare(forwardItemsList.count, 0) } } } |