diff options
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/dialogs/BLACKLIST | 8 | ||||
-rw-r--r-- | tests/auto/quick/publicapi/tst_publicapi.cpp | 31 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_action.qml | 16 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_download.qml | 93 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_findText.qml | 84 | ||||
-rw-r--r-- | tests/auto/quick/qquickwebengineview/BLACKLIST | 7 |
6 files changed, 222 insertions, 17 deletions
diff --git a/tests/auto/quick/dialogs/BLACKLIST b/tests/auto/quick/dialogs/BLACKLIST new file mode 100644 index 000000000..10b7391a0 --- /dev/null +++ b/tests/auto/quick/dialogs/BLACKLIST @@ -0,0 +1,8 @@ +[contextMenuRequested] +osx-10.13 +[javaScriptDialogRequested] +osx-10.13 +[colorDialogRequested] +osx-10.13 +[fileDialogRequested] +osx-10.13 diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index 90b768ac7..9f7dfa8ad 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -35,6 +35,7 @@ #include <QtTest/QtTest> #include <QtWebEngine/QQuickWebEngineProfile> #include <QtWebEngine/QQuickWebEngineScript> +#include <QtWebEngineCore/QWebEngineFindTextResult> #include <QtWebEngineCore/QWebEngineNotification> #include <QtWebEngineCore/QWebEngineQuotaRequest> #include <QtWebEngineCore/QWebEngineRegisterProtocolHandlerRequest> @@ -80,10 +81,12 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject * << &QQuickWebEngineColorDialogRequest::staticMetaObject << &QQuickWebEngineFileDialogRequest::staticMetaObject << &QQuickWebEngineFormValidationMessageRequest::staticMetaObject + << &QQuickWebEngineTooltipRequest::staticMetaObject << &QQuickWebEngineContextMenuRequest::staticMetaObject << &QWebEngineQuotaRequest::staticMetaObject << &QWebEngineRegisterProtocolHandlerRequest::staticMetaObject << &QWebEngineNotification::staticMetaObject + << &QWebEngineFindTextResult::staticMetaObject ; static QList<const char *> knownEnumNames = QList<const char *>(); @@ -259,6 +262,12 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineDownloadItem.type --> DownloadType" << "QQuickWebEngineDownloadItem.typeChanged() --> void" << "QQuickWebEngineDownloadItem.view --> QQuickWebEngineView*" + << "QQuickWebEngineDownloadItem.url --> QUrl" + << "QQuickWebEngineDownloadItem.suggestedFileName --> QString" + << "QQuickWebEngineDownloadItem.downloadDirectory --> QString" + << "QQuickWebEngineDownloadItem.downloadDirectoryChanged() --> void" + << "QQuickWebEngineDownloadItem.downloadFileName --> QString" + << "QQuickWebEngineDownloadItem.downloadFileNameChanged() --> void" << "QQuickWebEngineFileDialogRequest.FileModeOpen --> FileMode" << "QQuickWebEngineFileDialogRequest.FileModeOpenMultiple --> FileMode" << "QQuickWebEngineFileDialogRequest.FileModeSave --> FileMode" @@ -269,6 +278,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineFileDialogRequest.dialogAccept(QStringList) --> void" << "QQuickWebEngineFileDialogRequest.dialogReject() --> void" << "QQuickWebEngineFileDialogRequest.mode --> FileMode" + << "QWebEngineFindTextResult.numberOfMatches --> int" + << "QWebEngineFindTextResult.activeMatchOrdinal --> int" << "QQuickWebEngineFormValidationMessageRequest.Hide --> RequestType" << "QQuickWebEngineFormValidationMessageRequest.Move --> RequestType" << "QQuickWebEngineFormValidationMessageRequest.Show --> RequestType" @@ -277,6 +288,13 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineFormValidationMessageRequest.subText --> QString" << "QQuickWebEngineFormValidationMessageRequest.text --> QString" << "QQuickWebEngineFormValidationMessageRequest.type --> RequestType" + << "QQuickWebEngineTooltipRequest.Hide --> RequestType" + << "QQuickWebEngineTooltipRequest.Show --> RequestType" + << "QQuickWebEngineTooltipRequest.x --> int" + << "QQuickWebEngineTooltipRequest.y --> int" + << "QQuickWebEngineTooltipRequest.text --> QString" + << "QQuickWebEngineTooltipRequest.type --> RequestType" + << "QQuickWebEngineTooltipRequest.accepted --> bool" << "QQuickWebEngineFullScreenRequest.accept() --> void" << "QQuickWebEngineFullScreenRequest.origin --> QUrl" << "QQuickWebEngineFullScreenRequest.reject() --> void" @@ -596,6 +614,9 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.LetterExtra --> PrintedPageSizeId" << "QQuickWebEngineView.LetterPlus --> PrintedPageSizeId" << "QQuickWebEngineView.LetterSmall --> PrintedPageSizeId" + << "QQuickWebEngineView.LifecycleState.Active --> LifecycleState" + << "QQuickWebEngineView.LifecycleState.Discarded --> LifecycleState" + << "QQuickWebEngineView.LifecycleState.Frozen --> LifecycleState" << "QQuickWebEngineView.LinkClickedNavigation --> NavigationType" << "QQuickWebEngineView.LoadFailedStatus --> LoadStatus" << "QQuickWebEngineView.LoadStartedStatus --> LoadStatus" @@ -628,6 +649,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.Prc32K --> PrintedPageSizeId" << "QQuickWebEngineView.Prc32KBig --> PrintedPageSizeId" << "QQuickWebEngineView.Quarto --> PrintedPageSizeId" + << "QQuickWebEngineView.RedirectNavigation --> NavigationType" << "QQuickWebEngineView.Redo --> WebAction" << "QQuickWebEngineView.Reload --> WebAction" << "QQuickWebEngineView.ReloadAndBypassCache --> WebAction" @@ -676,6 +698,7 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.findText(QString) --> void" << "QQuickWebEngineView.findText(QString,FindFlags) --> void" << "QQuickWebEngineView.findText(QString,FindFlags,QJSValue) --> void" + << "QQuickWebEngineView.findTextFinished(QWebEngineFindTextResult) --> void" << "QQuickWebEngineView.formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest*) --> void" << "QQuickWebEngineView.fullScreenCancelled() --> void" << "QQuickWebEngineView.fullScreenRequested(QQuickWebEngineFullScreenRequest) --> void" @@ -692,6 +715,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.isFullScreenChanged() --> void" << "QQuickWebEngineView.javaScriptConsoleMessage(JavaScriptConsoleMessageLevel,QString,int,QString) --> void" << "QQuickWebEngineView.javaScriptDialogRequested(QQuickWebEngineJavaScriptDialogRequest*) --> void" + << "QQuickWebEngineView.lifecycleState --> LifecycleState" + << "QQuickWebEngineView.lifecycleStateChanged(LifecycleState) --> void" << "QQuickWebEngineView.linkHovered(QUrl) --> void" << "QQuickWebEngineView.loadHtml(QString) --> void" << "QQuickWebEngineView.loadHtml(QString,QUrl) --> void" @@ -715,6 +740,8 @@ static const QStringList expectedAPI = QStringList() << "QQuickWebEngineView.quotaRequested(QWebEngineQuotaRequest) --> void" << "QQuickWebEngineView.recentlyAudible --> bool" << "QQuickWebEngineView.recentlyAudibleChanged(bool) --> void" + << "QQuickWebEngineView.recommendedState --> LifecycleState" + << "QQuickWebEngineView.recommendedStateChanged(LifecycleState) --> void" << "QQuickWebEngineView.registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest) --> void" << "QQuickWebEngineView.reload() --> void" << "QQuickWebEngineView.reloadAndBypassCache() --> void" @@ -736,6 +763,7 @@ static const QStringList expectedAPI = QStringList() #endif << "QQuickWebEngineView.title --> QString" << "QQuickWebEngineView.titleChanged() --> void" + << "QQuickWebEngineView.tooltipRequested(QQuickWebEngineTooltipRequest*) --> void" << "QQuickWebEngineView.triggerWebAction(WebAction) --> void" << "QQuickWebEngineView.url --> QUrl" << "QQuickWebEngineView.urlChanged() --> void" @@ -811,8 +839,9 @@ static void checkKnownType(const QByteArray &typeName) static void gatherAPI(const QString &prefix, const QMetaEnum &metaEnum, QStringList *output) { + const auto format = metaEnum.isScoped() ? "%1%3.%2 --> %3" : "%1%2 --> %3"; for (int i = 0; i < metaEnum.keyCount(); ++i) - *output << QString::fromLatin1("%1%2 --> %3").arg(prefix).arg(metaEnum.key(i)).arg(metaEnum.name()); + *output << QString::fromLatin1(format).arg(prefix).arg(metaEnum.key(i)).arg(metaEnum.name()); } static void gatherAPI(const QString &prefix, const QMetaProperty &property, QStringList *output) diff --git a/tests/auto/quick/qmltests/data/tst_action.qml b/tests/auto/quick/qmltests/data/tst_action.qml index 56a91d8d0..852d4145a 100644 --- a/tests/auto/quick/qmltests/data/tst_action.qml +++ b/tests/auto/quick/qmltests/data/tst_action.qml @@ -51,8 +51,8 @@ TestWebEngineView { { webAction: WebEngineView.Forward, text: "Forward", iconName: "go-next", enabled: false }, { webAction: WebEngineView.Stop, text: "Stop", iconName: "", enabled: false }, { webAction: WebEngineView.Reload, text: "Reload", iconName: "view-refresh", enabled: true }, - { webAction: WebEngineView.Cut, text: "Cut", iconName: "Cut", enabled: true }, - { webAction: WebEngineView.Copy, text: "Copy", iconName: "", enabled: true }, + { webAction: WebEngineView.Cut, text: "Cut", iconName: "Cut", enabled: false }, + { webAction: WebEngineView.Copy, text: "Copy", iconName: "", enabled: false }, { webAction: WebEngineView.Paste, text: "Paste", iconName: "", enabled: true }, { webAction: WebEngineView.Undo, text: "Undo", iconName: "", enabled: true }, { webAction: WebEngineView.Redo, text: "Redo", iconName: "", enabled: true }, @@ -76,7 +76,7 @@ TestWebEngineView { { webAction: WebEngineView.InspectElement, text: "Inspect", iconName: "", enabled: true }, { webAction: WebEngineView.ExitFullScreen, text: "Exit full screen", iconName: "", enabled: true }, { webAction: WebEngineView.RequestClose, text: "Close Page", iconName: "", enabled: true }, - { webAction: WebEngineView.Unselect, text: "Unselect", iconName: "", enabled: true }, + { webAction: WebEngineView.Unselect, text: "Unselect", iconName: "", enabled: false }, { webAction: WebEngineView.SavePage, text: "Save page", iconName: "", enabled: true }, { webAction: WebEngineView.ViewSource, text: "View page source", iconName: "view-source", enabled: true }, { webAction: WebEngineView.ToggleBold, text: "&Bold", iconName: "", enabled: true }, @@ -110,17 +110,17 @@ TestWebEngineView { webEngineView.url = Qt.resolvedUrl("test1.html"); verify(webEngineView.waitForLoadSucceeded()); - var copyAction = webEngineView.action(WebEngineView.Copy); - verify(copyAction); + var selectAction = webEngineView.action(WebEngineView.SelectAll); + verify(selectAction); var stopAction = webEngineView.action(WebEngineView.Stop); verify(stopAction); - var triggerSpy = createTemporaryObject(signalSpy, actionTests, {target: copyAction, signalName: "triggered"}); + var triggerSpy = createTemporaryObject(signalSpy, actionTests, {target: selectAction, signalName: "triggered"}); var stopTriggerSpy = createTemporaryObject(signalSpy, actionTests, {target: stopAction, signalName: "triggered"}); - verify(copyAction.enabled); - copyAction.trigger(); + verify(selectAction.enabled); + selectAction.trigger(); compare(triggerSpy.count, 1); verify(!stopAction.enabled); diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml index 5eb704cce..e049f3621 100644 --- a/tests/auto/quick/qmltests/data/tst_download.qml +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -28,7 +28,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtWebEngine 1.9 +import QtWebEngine 1.10 import Qt.labs.platform 1.0 TestWebEngineView { @@ -42,10 +42,22 @@ TestWebEngineView { property bool cancelDownload: false property var downloadState: [] property var downloadInterruptReason: null + property url downloadUrl: "" + property string suggestedFileName: "" + property string downloadDirectory: "" + property string downloadFileName: "" + property string downloadedPath: "" + property string downloadedSetPath: "" + property int downloadDirectoryChanged: 0 + property int downloadFileNameChanged: 0 + property int downloadPathChanged: 0 function urlToPath(url) { var path = url.toString() - path = path.replace(/^(file:\/{2})/,"") + if (Qt.platform.os !== "windows") + path = path.replace(/^(file:\/{2})/, "") + else + path = path.replace(/^(file:\/{3})/, "") return path } @@ -66,21 +78,36 @@ TestWebEngineView { ignoreUnknownSignals: true onStateChanged: downloadState.push(target.state) onInterruptReasonChanged: downloadInterruptReason = target.interruptReason + onDownloadDirectoryChanged: downloadDirectoryChanged++ + onDownloadFileNameChanged: downloadFileNameChanged++ + onPathChanged: downloadPathChanged++ } WebEngineProfile { id: testDownloadProfile onDownloadRequested: { + testDownloadProfile.downloadPath = urlToPath(StandardPaths.writableLocation(StandardPaths.TempLocation)) downloadState.push(download.state) downloadItemConnections.target = download if (cancelDownload) { download.cancel() } else { totalBytes = download.totalBytes - download.path = "testfile.zip" + + if (downloadedSetPath.length != 0) { + 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" + downloadedPath = download.downloadDirectory + download.downloadFileName + } + download.accept() } + downloadUrl = download.url + suggestedFileName = download.suggestedFileName } onDownloadFinished: { receivedBytes = download.receivedBytes; @@ -99,6 +126,13 @@ TestWebEngineView { downloadItemConnections.target = null downloadState = [] downloadInterruptReason = null + downloadDirectoryChanged = 0 + downloadFileNameChanged = 0 + downloadPathChanged = 0 + downloadDirectory = "" + downloadFileName = "" + downloadedPath = "" + downloadedSetPath = "" } function test_downloadRequest() { @@ -106,6 +140,8 @@ TestWebEngineView { 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) verify(!downloadInterruptReason) } @@ -115,6 +151,8 @@ TestWebEngineView { webEngineView.url = Qt.resolvedUrl("download.zip") downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) + compare(downloadUrl, webEngineView.url) + compare(suggestedFileName, "download.zip") compare(totalBytes, 325) verify(!downloadInterruptReason) } @@ -124,6 +162,8 @@ TestWebEngineView { 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) downloadFinishedSpy.wait() @@ -138,6 +178,8 @@ TestWebEngineView { webEngineView.url = Qt.resolvedUrl("download.zip") downLoadRequestedSpy.wait() compare(downLoadRequestedSpy.count, 1) + compare(downloadUrl, webEngineView.url) + compare(suggestedFileName, "download.zip") compare(downloadFinishedSpy.count, 1) tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadCancelled) tryCompare(webEngineView, "downloadInterruptReason", WebEngineDownloadItem.UserCanceled) @@ -153,5 +195,50 @@ TestWebEngineView { testDownloadProfile.downloadPath = downloadPath; compare(testDownloadProfile.downloadPath, downloadPath); } + + function test_downloadToDirectoryWithFileName() { + compare(downLoadRequestedSpy.count, 0); + compare(downloadDirectoryChanged, 0); + compare(downloadFileNameChanged, 0); + downloadDirectory = "/test/"; + downloadFileName = "test.zip"; + 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 + downloadFileName); + compare(downloadDirectoryChanged, 1); + compare(downloadFileNameChanged, 1); + compare(downloadPathChanged, 2); + 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"; + 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 + downloadedSetPath); + compare(downloadDirectoryChanged, 1); + compare(downloadFileNameChanged, 1); + compare(downloadPathChanged, 2); + downloadFinishedSpy.wait(); + compare(totalBytes, receivedBytes); + tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted); + verify(!downloadInterruptReason); + } } } diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index 14053a675..040d324e6 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -38,9 +38,16 @@ TestWebEngineView { property int matchCount: 0 property bool findFailed: false + SignalSpy { + id: findTextSpy + target: webEngineView + signalName: "findTextFinished" + } + function clear() { findFailed = false matchCount = -1 + findTextSpy.clear() } function findCallbackCalled() { return matchCount != -1 } @@ -104,6 +111,9 @@ TestWebEngineView { webEngineView.findText("Hello", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 1) verify(!findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) } function test_findTextCaseInsensitive() { @@ -115,6 +125,9 @@ TestWebEngineView { webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 1) verify(!findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) } function test_findTextManyMatches() { @@ -126,6 +139,9 @@ TestWebEngineView { webEngineView.findText("bla", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 100, 20000) verify(!findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 100) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) } @@ -138,6 +154,9 @@ TestWebEngineView { webEngineView.findText("heLLo", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 0) verify(findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) } function test_findTextNotFound() { @@ -149,6 +168,9 @@ TestWebEngineView { webEngineView.findText("string-that-is-not-threre", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 0) verify(findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) } function test_findTextAfterNotFound() { @@ -160,6 +182,9 @@ TestWebEngineView { webEngineView.findText("hello", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 0) verify(findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) webEngineView.url = Qt.resolvedUrl("test1.html") verify(webEngineView.waitForLoadSucceeded()) @@ -168,6 +193,9 @@ TestWebEngineView { webEngineView.findText("hello", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 1) verify(!findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) } function test_findTextInModifiedDOMAfterNotFound() { @@ -182,6 +210,9 @@ TestWebEngineView { webEngineView.findText("hello", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 0, 20000) verify(findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0) runJavaScript("document.body.innerHTML = 'blahellobla'"); tryVerify(function() { return getBodyInnerHTML() == "blahellobla"; }, 20000); @@ -190,6 +221,9 @@ TestWebEngineView { webEngineView.findText("hello", findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, "matchCount", 1) verify(!findFailed) + tryCompare(findTextSpy, "count", 1) + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 1) + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1) } function test_findTextInterruptedByLoad() { @@ -227,5 +261,55 @@ TestWebEngineView { webEngineView.findText('New page', findFlags, webEngineView.findTextCallback) tryCompare(webEngineView, 'matchCount', 1) } + + function test_findTextActiveMatchOrdinal() { + webEngineView.loadHtml( + "<html><body>" + + "foo bar foo bar foo" + + "</body></html>"); + verify(webEngineView.waitForLoadSucceeded()); + + // Iterate over all "foo" matches. + webEngineView.clear(); + for (var i = 1; i <= 3; ++i) { + webEngineView.findText("foo"); + findTextSpy.wait(); + compare(findTextSpy.count, i); + compare(findTextSpy.signalArguments[i-1][0].numberOfMatches, 3); + compare(findTextSpy.signalArguments[i-1][0].activeMatchOrdinal, i); + } + + // The last match is followed by the fist one. + webEngineView.clear(); + webEngineView.findText("foo"); + findTextSpy.wait(); + compare(findTextSpy.count, 1); + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 3); + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1); + + // The first match is preceded by the last one. + webEngineView.clear(); + webEngineView.findText("foo", WebEngineView.FindBackward); + findTextSpy.wait(); + compare(findTextSpy.count, 1); + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 3); + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 3); + + // Finding another word resets the activeMatchOrdinal. + webEngineView.clear(); + webEngineView.findText("bar"); + findTextSpy.wait(); + compare(findTextSpy.count, 1); + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 2); + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 1); + + // If no match activeMatchOrdinal is 0. + webEngineView.clear(); + webEngineView.findText("bla"); + findTextSpy.wait(); + compare(findTextSpy.count, 1); + compare(findTextSpy.signalArguments[0][0].numberOfMatches, 0); + compare(findTextSpy.signalArguments[0][0].activeMatchOrdinal, 0); + } } } diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST index 49c5332ff..d4d5c9844 100644 --- a/tests/auto/quick/qquickwebengineview/BLACKLIST +++ b/tests/auto/quick/qquickwebengineview/BLACKLIST @@ -1,5 +1,2 @@ -[javascriptClipboard:default] -opensuse-leap - -[javascriptClipboard:canPaste] -opensuse-leap +[transparentWebEngineViews] +windows |