diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-06 14:44:00 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-06 14:44:00 +0100 |
commit | 40736c5763bf61337c8c14e16d8587db021a87d4 (patch) | |
tree | b17a9c00042ad89cb1308e2484491799aa14e9f8 /Source/WebKit2/UIProcess/API/qt/tests |
Imported WebKit commit 2ea9d364d0f6efa8fa64acf19f451504c59be0e4 (http://svn.webkit.org/repository/webkit/trunk@104285)
Diffstat (limited to 'Source/WebKit2/UIProcess/API/qt/tests')
48 files changed, 2116 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html new file mode 100644 index 000000000..b4eea41bd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html @@ -0,0 +1 @@ +<h1>Basic page</h1> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html new file mode 100644 index 000000000..f8cff2969 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html @@ -0,0 +1 @@ +<h1>Basic page 2</h1> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html b/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html new file mode 100644 index 000000000..2fd91418a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html @@ -0,0 +1,66 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> + +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Testing direct image layer optimisation</title> + <style type="text/css" media="screen"> + img { + float: left; + width: 150px; + height: 150px; + } + img { + -webkit-transform: rotate3d(0, 0, 1, 0); + } + .test { + float: left; + height: 200px; + width: 260px; + } + </style> +</head> +<body> + + <h1>Image optimisation in layers</h1> + + <p> + This test exercises direct compositing of images with hardware acceleration. The visual results + using ACCELERATED_COMPOSITING and regular TOT should be identical. Running this test manually with + the correct debug options will show which elements are directly composited. See + <a href="https://bugs.webkit.org/show_bug.cgi?id=23361">https://bugs.webkit.org/show_bug.cgi?id=23361</a> + </p> + + <div class="test"> + <img src="resources/simple_image.png"> + Basic image - no style - can be directly composited + </div> + + <div class="test"> + <img src="resources/simple_image.png" style="border: 5px solid blue;"> + 5px blue border - can NOT be directly composited + </div> + + <div class="test"> + <img src="resources/simple_image.png" style="margin: 5px 5px;"> + margin - can NOT be directly composited + </div> + + <div class="test"> + <img src="resources/simple_image.png" style="background-color: grey;"> + solid background - can be directly composited + </div> + + <div class="test"> + <img src="resources/simple_image.png" style="background: orange url(resources/simple_image.png) -50px -50px;"> + background image - can NOT be directly composited + </div> + + <div class="test"> + <img src="resources/simple_image.png" style="-webkit-transform: rotate3d(0, 0, 1, 10deg);"> + rotated but otherwise no style - can be directly composited + </div> + +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png Binary files differnew file mode 100644 index 000000000..4685399ca --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html b/Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html new file mode 100644 index 000000000..6b9b2d652 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> +<meta name="viewport" content="width=200, height=500, user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1"/> +<script type="text/javascript"> +function pageScroll() { + window.scrollBy(0,50); // horizontal and vertical scroll increments +} +</script> +<style> + body { + background-color: blue; + margin: 50 50 50 50; + } + div { + font-color: white; + background-color: green; + width: 300px; + height: 1000px; + } +</style> + +<head> +<title>Scroll test </title> +</head> +<body onload="pageScroll()"> +<div> +</div> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml new file mode 100644 index 000000000..4dce0918b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +WebView { + id: component + experimental.useTraditionalDesktopBehaviour: true +} + diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml new file mode 100644 index 000000000..c98958319 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml @@ -0,0 +1,85 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +DesktopWebView { + id: webView + width: 200 + height: 400 + focus: true + + property string lastUrl + property string lastTitle + + SignalSpy { + id: spy + target: webView + signalName: "linkHovered" + } + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + onLinkHovered: { + webView.lastUrl = url + webView.lastTitle = title + } + + TestCase { + name: "DesktopWebViewLinkHovered" + + // Delayed windowShown to workaround problems with Qt5 in debug mode. + when: false + Timer { + running: parent.windowShown + repeat: false + interval: 1 + onTriggered: parent.when = true + } + + function init() { + webView.lastUrl = "" + webView.lastTitle = "" + spy.clear() + } + + function test_linkHovered() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/test2.html")) + loadSpy.wait() + mouseMove(webView, 100, 100) + spy.wait() + compare(spy.count, 1) + compare(webView.lastUrl, Qt.resolvedUrl("../common/test1.html")) + compare(webView.lastTitle, "A title") + mouseMove(webView, 100, 300) + spy.wait() + compare(spy.count, 2) + compare(webView.lastUrl, "") + compare(webView.lastTitle, "") + } + + function test_linkHoveredDoesntEmitRepeated() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/test2.html")) + loadSpy.wait() + + for (var i = 0; i < 100; i += 10) + mouseMove(webView, 100, 100 + i) + + spy.wait() + compare(spy.count, 1) + compare(webView.lastUrl, Qt.resolvedUrl("../common/test1.html")) + + for (var i = 0; i < 100; i += 10) + mouseMove(webView, 100, 300 + i) + + spy.wait() + compare(spy.count, 2) + compare(webView.lastUrl, "") + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml new file mode 100644 index 000000000..b45b01ac8 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +DesktopWebView { + id: webView + width: 200 + height: 400 + focus: true + + property string lastUrl + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + SignalSpy { + id: linkHoveredSpy + target: webView + signalName: "linkHovered" + } + + onLinkHovered: { + webView.lastUrl = url + } + + TestCase { + name: "DesktopWebViewLoadHtml" + + // Delayed windowShown to workaround problems with Qt5 in debug mode. + when: false + Timer { + running: parent.windowShown + repeat: false + interval: 1 + onTriggered: parent.when = true + } + + function init() { + webView.lastUrl = "" + linkHoveredSpy.clear() + loadSpy.clear() + } + + function test_baseUrlAfterLoadHtml() { + loadSpy.clear() + linkHoveredSpy.clear() + compare(linkHoveredSpy.count, 0) + webView.loadHtml("<html><head><title>Test page with huge link area</title></head><body><a title=\"A title\" href=\"test1.html\"><img width=200 height=200></a></body></html>", "http://www.example.foo.com") + loadSpy.wait() + compare("http://www.example.foo.com/", webView.url) + mouseMove(webView, 100, 100) + linkHoveredSpy.wait() + compare(linkHoveredSpy.count, 1) + compare(webView.lastUrl, "http://www.example.foo.com/test1.html") + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml new file mode 100644 index 000000000..7fcc91a64 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml @@ -0,0 +1,108 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +Item { + DesktopWebView { + id: webView + property variant lastMessage + experimental.preferences.navigatorQtObjectEnabled: true + experimental.onMessageReceived: { + lastMessage = message + } + } + + DesktopWebView { + id: otherWebView + property variant lastMessage + experimental.preferences.navigatorQtObjectEnabled: true + experimental.onMessageReceived: { + lastMessage = message + } + } + + DesktopWebView { + id: disabledWebView + property bool receivedMessage + experimental.preferences.navigatorQtObjectEnabled: false + experimental.onMessageReceived: { + receivedMessage = true + } + } + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + SignalSpy { + id: messageSpy + target: webView.experimental + signalName: "messageReceived" + } + + SignalSpy { + id: otherLoadSpy + target: otherWebView + signalName: "loadSucceeded" + } + + SignalSpy { + id: otherMessageSpy + target: otherWebView.experimental + signalName: "messageReceived" + } + + SignalSpy { + id: disabledWebViewLoadSpy + target: disabledWebView + signalName: "loadSucceeded" + } + + TestCase { + name: "DesktopWebViewMessaging" + property url testUrl: Qt.resolvedUrl("../common/messaging.html") + + function init() { + loadSpy.clear() + messageSpy.clear() + webView.lastMessage = null + otherLoadSpy.clear() + otherMessageSpy.clear() + otherWebView.lastMessage = null + } + + function test_basic() { + webView.load(testUrl) + loadSpy.wait() + webView.experimental.postMessage("HELLO") + messageSpy.wait() + compare(webView.lastMessage.data, "OLLEH") + compare(webView.lastMessage.origin.toString(), testUrl.toString()) + } + + function test_twoWebViews() { + webView.load(testUrl) + otherWebView.load(testUrl) + loadSpy.wait() + otherLoadSpy.wait() + webView.experimental.postMessage("FIRST") + otherWebView.experimental.postMessage("SECOND") + messageSpy.wait() + otherMessageSpy.wait() + compare(webView.lastMessage.data, "TSRIF") + compare(otherWebView.lastMessage.data, "DNOCES") + } + + function test_disabled() { + disabledWebView.load(testUrl) + verify(!disabledWebView.experimental.preferences.navigatorQtObjectEnabled) + disabledWebViewLoadSpy.wait() + disabledWebView.experimental.postMessage("HI") + wait(1000) + verify(!disabledWebView.receivedMessage) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml new file mode 100644 index 000000000..3ef7d5516 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml @@ -0,0 +1,151 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +Item { + property int expectedLength: 0 + property int totalBytes: 0 + property bool shouldDownload: false + property string originatingUrl: "" + property url beginUrl: Qt.resolvedUrl("../common/test2.html") + property url endUrl: Qt.resolvedUrl("../common/test1.html") + + DesktopWebView { + id: webView + width: 200 + height: 200 + + signal downloadFinished() + + onNavigationRequested: { + if (shouldDownload) + request.action = WebViewExperimental.DownloadRequest + else if (request.button == Qt.MiddleButton && request.modifiers & Qt.ControlModifier) { + otherWebView.load(request.url) + request.action = WebView.IgnoreRequest + } + originatingUrl = request.originatingUrl + } + + experimental.onDownloadRequested: { + download.target = downloadItem + expectedLength = downloadItem.expectedContentLength + downloadItem.destinationPath = downloadItem.suggestedFilename + downloadItem.start() + } + + Connections { + id: download + ignoreUnknownSignals: true + onSucceeded: { + totalBytes = download.target.totalBytesReceived + webView.downloadFinished() + } + } + } + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + DesktopWebView { + id: otherWebView + } + + SignalSpy { + id: otherSpy + target: otherWebView + signalName: "loadSucceeded" + } + + SignalSpy { + id: downloadSpy + target: webView.experimental + signalName: "downloadRequested" + } + + SignalSpy { + id: downloadFinishedSpy + target: webView + signalName: "downloadFinished" + } + + TestCase { + name: "DesktopWebViewNavigationRequested" + + // Delayed windowShown to workaround problems with Qt5 in debug mode. + when: false + Timer { + running: parent.windowShown + repeat: false + interval: 1 + onTriggered: parent.when = true + } + + function init() { + spy.clear() + otherSpy.clear() + downloadSpy.clear() + downloadFinishedSpy.clear() + shouldDownload = false + originatingUrl = "" + } + + function test_usePolicy() { + webView.load(beginUrl) + spy.wait() + spy.clear() + mouseClick(webView, 100, 100, Qt.LeftButton) + spy.wait() + compare(spy.count, 1) + compare(webView.title, "Test page 1") + compare(webView.url, endUrl) + } + + function test_ignorePolicy() { + webView.load(beginUrl) + spy.wait() + spy.clear() + compare(spy.count, 0) + compare(otherSpy.count, 0) + mouseClick(webView, 100, 100, Qt.MiddleButton, Qt.ControlModifier) + otherSpy.wait() + compare(spy.count, 0) + compare(otherSpy.count, 1) + compare(webView.url, beginUrl) + compare(otherWebView.title, "Test page 1") + compare(otherWebView.url, endUrl) + } + + function test_downloadPolicy() { + webView.load(beginUrl) + spy.wait() + spy.clear() + compare(spy.count, 0) + downloadSpy.clear() + downloadFinishedSpy.clear() + expectedLength = 0 + shouldDownload = true + mouseClick(webView, 100, 100, Qt.LeftButton) + downloadSpy.wait() + compare(downloadSpy.count, 1) + downloadFinishedSpy.wait() + compare(downloadFinishedSpy.count, 1) + compare(totalBytes, expectedLength) + } + + function test_originatingUrl() { + webView.load(beginUrl) + spy.wait() + spy.clear() + mouseClick(webView, 100, 100, Qt.LeftButton) + spy.wait() + compare(webView.title, "Test page 1") + compare(webView.url, endUrl) + compare(originatingUrl, beginUrl) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml new file mode 100644 index 000000000..29774e117 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + experimental { + urlSchemeDelegates: [ + UrlSchemeDelegate { + scheme: "applicationScheme" + onReceivedRequest: { + reply.data = "<html><head><title>Test Application Scheme</title></head><body>A test page.</body></html>" + reply.send() + } + } + ] + } + + SignalSpy { + id: spyTitle + target: webView + signalName: "titleChanged" + } + + TestCase { + name: "WebViewApplicationSchemes" + + function test_applicationScheme() { + compare(spyTitle.count, 0) + var testUrl = "applicationScheme://something" + webView.load(testUrl) + spyTitle.wait() + compare(webView.title, "Test Application Scheme") + } + } + +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml new file mode 100644 index 000000000..6c25af3bc --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml @@ -0,0 +1,86 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +WebView { + id: webView + width: 200 + height: 200 + + property int expectedLength: 0 + property int totalBytes: 0 + + signal downloadFinished() + + SignalSpy { + id: spy + target: experimental + signalName: "downloadRequested" + } + + SignalSpy { + id: downloadFinishedSpy + target: webView + signalName: "downloadFinished" + } + + experimental.onDownloadRequested: { + download.target = downloadItem + expectedLength = downloadItem.expectedContentLength + downloadItem.destinationPath = downloadItem.suggestedFilename + downloadItem.start() + } + + Connections { + id: download + ignoreUnknownSignals: true + onSucceeded: { + totalBytes = download.target.totalBytesReceived + webView.downloadFinished() + } + } + + TestCase { + name: "WebViewDownload" + + // Delayed windowShown to workaround problems with Qt5 in debug mode. + when: false + Timer { + running: parent.windowShown + repeat: false + interval: 1 + onTriggered: parent.when = true + } + + function init() { + spy.clear() + downloadFinishedSpy.clear() + expectedLength = 0 + } + + function test_downloadRequest() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/download.zip")) + spy.wait() + compare(spy.count, 1) + } + + function test_expectedLength() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/download.zip")) + spy.wait() + compare(spy.count, 1) + compare(expectedLength, 325) + } + + function test_succeeded() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/download.zip")) + spy.wait() + compare(spy.count, 1) + downloadFinishedSpy.wait() + compare(totalBytes, expectedLength) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml new file mode 100644 index 000000000..121809316 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + + SignalSpy { + id: spy + target: webView + signalName: "iconChanged" + } + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + Image { + id: favicon + source: webView.icon + } + + TestCase { + id: test + name: "WebViewLoadFavIcon" + + function init() { + if (webView.icon != '') { + // If this is not the first test, then load a blank page without favicon, restoring the initial state. + webView.load('about:blank') + spy.wait() + loadSpy.wait() + } + loadSpy.clear() + spy.clear() + } + + function test_favIconLoad() { + compare(spy.count, 0) + var url = Qt.resolvedUrl("../common/favicon.html") + webView.load(url) + spy.wait() + compare(spy.count, 1) + compare(favicon.width, 48) + compare(favicon.height, 48) + } + + function test_favIconLoadEncodedUrl() { + compare(spy.count, 0) + var url = Qt.resolvedUrl("../common/favicon2.html?favicon=load should work with#whitespace!") + webView.load(url) + spy.wait() + compare(spy.count, 1) + compare(favicon.width, 16) + compare(favicon.height, 16) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml new file mode 100644 index 000000000..697ab085a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +WebView { + id: webView + width: 200 + height: 200 + + property bool expectedPermission: false + + SignalSpy { + id: spy + target: experimental + signalName: "permissionRequested" + } + + experimental.onPermissionRequested: { + //Must be false by default + if (!permission.allow) { + permission.allow = true + } else + console.log("Fail: permission must be set to false") + + if (permission.type == PermissionRequest.Geolocation) { + console.log("Permission is geotype") + } + } + + TestCase { + name: "WebViewGeopermission" + + // Delayed windowShown to workaround problems with Qt5 in debug mode. + when: false + Timer { + running: parent.windowShown + repeat: false + interval: 1 + onTriggered: parent.when = true + } + + function init() { + spy.clear() + } + + function test_permissionRequest() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/geolocation.html")) + spy.wait() + compare(spy.count, 1) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml new file mode 100644 index 000000000..03d68be5b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml @@ -0,0 +1,119 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +// FIXME: used because we want to have mouseClick() to open the <select> tag. We can remove this +// when TestCase starts supporting touch events, see https://bugreports.qt.nokia.com/browse/QTBUG-23083. +import "../DesktopBehavior" + +DesktopWebView { + id: webView + + width: 400 + height: 400 + + property int initialSelection + property int finalSelection + property bool useAcceptDirectly + property bool selectorLoaded + + experimental.itemSelector: Item { + Component.onCompleted: { + if (WebView.view.initialSelection != -1) + model.items.select(WebView.view.initialSelection) + + if (WebView.view.finalSelection == -1) + model.reject() + else { + if (useAcceptDirectly) { + model.accept(WebView.view.finalSelection) + } else { + model.items.select(WebView.view.finalSelection) + model.accept() + } + } + + WebView.view.selectorLoaded = true + } + } + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + SignalSpy { + id: titleSpy + target: webView + signalName: "titleChanged" + } + + TestCase { + id: test + name: "WebViewItemSelector" + when: windowShown + + function init() { + webView.initialSelection = -1 + webView.finalSelection = -1 + webView.useAcceptDirectly = false + webView.selectorLoaded = false + loadSpy.clear() + webView.load(Qt.resolvedUrl("../common/select.html")) + loadSpy.wait() + titleSpy.clear() + } + + function openItemSelector() { + mouseClick(webView, 15, 15, Qt.LeftButton) + } + + function test_accept() { + webView.finalSelection = 1 + openItemSelector() + titleSpy.wait() + compare(webView.title, "__closed__") + } + + function test_acceptDirectly() { + webView.finalSelection = 1 + webView.useAcceptDirectly = true + openItemSelector() + titleSpy.wait() + compare(webView.title, "__closed__") + } + + function test_selectFirstThenAccept() { + webView.initialSelection = 1 + webView.finalSelection = 2 + openItemSelector() + titleSpy.wait() + compare(webView.title, "__all__") + } + + function test_selectFirstThenAcceptDirectly() { + webView.initialSelection = 1 + webView.finalSelection = 2 + webView.useAcceptDirectly = true + openItemSelector() + titleSpy.wait() + compare(webView.title, "__all__") + } + + function test_reject() { + openItemSelector() + tryCompare(webView, "selectorLoaded", true) + compare(webView.title, "No new selection was made") + } + + function test_selectFirstThenReject() { + webView.initialSelection = 1 + webView.finalSelection = -1 + openItemSelector() + tryCompare(webView, "selectorLoaded", true) + compare(webView.title, "No new selection was made") + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml new file mode 100644 index 000000000..56c34abcd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml @@ -0,0 +1,125 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +WebView { + id: webView + + property bool modelMessageEqualsMessage: false + property string messageFromAlertDialog: "" + property int confirmCount: 0 + property int promptCount: 0 + + experimental.alertDialog: Item { + Timer { + running: true + interval: 1 + onTriggered: { + // Testing both attached property and id defined in the Component context. + parent.WebView.view.messageFromAlertDialog = message + webView.modelMessageEqualsMessage = Boolean(model.message == message) + model.dismiss() + } + } + } + + experimental.confirmDialog: Item { + Timer { + running: true + interval: 1 + onTriggered: { + parent.WebView.view.confirmCount += 1 + if (message == "ACCEPT") + model.accept() + else + model.reject() + } + } + } + + experimental.promptDialog: Item { + Timer { + running: true + interval: 1 + onTriggered: { + parent.WebView.view.promptCount += 1 + if (message == "REJECT") + model.reject() + else { + var reversedDefaultValue = defaultValue.split("").reverse().join("") + model.accept(reversedDefaultValue) + } + } + } + } + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + TestCase { + id: test + name: "WebViewJavaScriptDialogs" + + function init() { + webView.modelMessageEqualsMessage = false + webView.messageFromAlertDialog = "" + webView.confirmCount = 0 + webView.promptCount = 0 + loadSpy.clear() + } + + function test_alert() { + webView.load(Qt.resolvedUrl("../common/alert.html")) + loadSpy.wait() + compare(loadSpy.count, 1) + compare(webView.messageFromAlertDialog, "Hello Qt") + verify(webView.modelMessageEqualsMessage) + } + + function test_alertWithoutDialog() { + webView.experimental.alertDialog = null + webView.load(Qt.resolvedUrl("../common/alert.html")) + loadSpy.wait() + compare(loadSpy.count, 1) + compare(webView.messageFromAlertDialog, "") + } + + function test_confirm() { + webView.load(Qt.resolvedUrl("../common/confirm.html")) + loadSpy.wait() + compare(loadSpy.count, 1) + compare(webView.confirmCount, 2) + compare(webView.title, "ACCEPTED REJECTED") + } + + function test_confirmWithoutDialog() { + webView.experimental.confirmDialog = null + webView.load(Qt.resolvedUrl("../common/confirm.html")) + loadSpy.wait() + compare(loadSpy.count, 1) + compare(webView.confirmCount, 0) + compare(webView.title, "ACCEPTED ACCEPTED") + } + + function test_prompt() { + webView.load(Qt.resolvedUrl("../common/prompt.html")) + loadSpy.wait() + compare(loadSpy.count, 1) + compare(webView.promptCount, 2) + compare(webView.title, "tQ olleH") + } + + function test_promptWithoutDialog() { + webView.experimental.promptDialog = null + webView.load(Qt.resolvedUrl("../common/prompt.html")) + loadSpy.wait() + compare(loadSpy.count, 1) + compare(webView.promptCount, 0) + compare(webView.title, "FAIL") + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml new file mode 100644 index 000000000..26a42c0b7 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + property variant testUrl + + SignalSpy { + id: spy + target: webView + signalName: "loadFailed" + } + + TestCase { + id: test + name: "WebViewLoadFail" + function test_fail() { + compare(spy.count, 0) + testUrl = Qt.resolvedUrl("file_that_does_not_exist.html") + webView.load(testUrl) + spy.wait() + compare(spy.count, 1) + } + } + + onLoadFailed: { + test.compare(url, testUrl) + test.compare(errorCode, NetworkReply.ContentNotFoundError) + test.compare(errorDomain, WebView.NetworkErrorDomain) + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml new file mode 100644 index 000000000..b57df66a6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + width: 200 + height: 400 + + SignalSpy { + id: loadSpy + target: webView + signalName: "loadSucceeded" + } + + TestCase { + name: "WebViewLoadHtml" + + function test_loadProgressAfterLoadHtml() { + loadSpy.clear() + compare(loadSpy.count, 0) + compare(webView.loadProgress, 0) + webView.loadHtml("<html><head><title>Test page 1</title></head><body>Hello.</body></html>") + loadSpy.wait() + compare(webView.loadProgress, 100) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml new file mode 100644 index 000000000..a51d6f69f --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + TestCase { + name: "WebViewLoadProgress" + + function test_loadProgress() { + compare(spy.count, 0) + compare(webView.loadProgress, 0) + webView.load(Qt.resolvedUrl("../common/test1.html")) + compare(webView.loadProgress, 0) + spy.wait() + compare(webView.loadProgress, 100) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml new file mode 100644 index 000000000..10ac879a8 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml @@ -0,0 +1,38 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + SignalSpy { + id: spyProgress + target: webView + signalName: "loadProgressChanged" + } + + TestCase { + name: "WebViewLoadProgressSignal" + + function test_loadProgressSignal() { + compare(spyProgress.count, 0) + compare(webView.loadProgress, 0) + webView.load(Qt.resolvedUrl("../common/test1.html")) + spyProgress.wait() + compare(true, webView.loadProgress > -1 && webView.loadProgress < 101) + if (webView.loadProgress > 0 && webView.loadProgress < 100) { + spy.wait() + spyProgress.wait() + compare(webView.loadProgress, 100) + } + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml new file mode 100644 index 000000000..68aeeb556 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml @@ -0,0 +1,108 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + ListView { + id: backItemsList + anchors.fill: parent + model: webView.experimental.navigationHistory.backItems + delegate: + Text { + color:"black" + text: "title : " + title + } + } + + ListView { + id: forwardItemsList + anchors.fill: parent + model: webView.experimental.navigationHistory.forwardItems + delegate: + Text { + color:"black" + text: "title : " + title + } + } + + TestCase { + name: "WebViewNavigationHistory" + + function test_navigationHistory() { + compare(spy.count, 0) + compare(webView.loadProgress, 0) + webView.load(Qt.resolvedUrl("../common/test1.html")) + spy.wait() + compare(webView.canGoBack, false) + compare(webView.canGoForward, false) + compare(backItemsList.count, 0) + compare(forwardItemsList.count, 0) + spy.clear() + webView.load(Qt.resolvedUrl("../common/test2.html")) + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/test2.html")) + compare(webView.canGoBack, true) + compare(webView.canGoForward, false) + compare(backItemsList.count, 1) + spy.clear() + webView.experimental.goBackTo(0) + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/test1.html")) + compare(webView.canGoBack, false) + compare(webView.canGoForward, true) + compare(backItemsList.count, 0) + compare(forwardItemsList.count, 1) + spy.clear() + webView.goForward() + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/test2.html")) + compare(webView.canGoBack, true) + compare(webView.canGoForward, false) + compare(backItemsList.count, 1) + compare(forwardItemsList.count, 0) + spy.clear() + webView.load(Qt.resolvedUrl("../common/javascript.html")) + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/javascript.html")) + compare(webView.canGoBack, true) + compare(webView.canGoForward, false) + compare(backItemsList.count, 2) + compare(forwardItemsList.count, 0) + spy.clear() + webView.experimental.goBackTo(1) + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/test1.html")) + compare(webView.canGoBack, false) + compare(webView.canGoForward, true) + compare(backItemsList.count, 0) + compare(forwardItemsList.count, 2) + spy.clear() + webView.experimental.goForwardTo(1) + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/javascript.html")) + compare(webView.canGoBack, true) + compare(webView.canGoForward, false) + compare(backItemsList.count, 2) + compare(forwardItemsList.count, 0) + spy.clear() + webView.goBack() + spy.wait() + compare(webView.url, Qt.resolvedUrl("../common/test2.html")) + compare(webView.canGoBack, true) + compare(webView.canGoForward, true) + compare(backItemsList.count, 1) + compare(forwardItemsList.count, 1) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml new file mode 100644 index 000000000..0554abb2d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml @@ -0,0 +1,101 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 3.0 + +Item { + WebView { + id: webView + width: 400 + height: 300 + + experimental.preferences.javascriptEnabled: true + experimental.preferences.localStorageEnabled: true + experimental.preferences.pluginsEnabled: true + + WebView { + id: webView2 + width: 400 + height: 300 + } + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + SignalSpy { + id: otherSpy + target: webView2 + signalName: "loadSucceeded" + } + + TestCase { + name: "WebViewPreferences" + + function init() { + webView.experimental.preferences.javascriptEnabled = true + webView.experimental.preferences.localStorageEnabled = true + webView.experimental.preferences.pluginsEnabled = true + spy.clear() + } + + function test_javascriptEnabled() { + webView.experimental.preferences.javascriptEnabled = true + var testUrl = Qt.resolvedUrl("../common/javascript.html") + webView.load(testUrl) + spy.wait() + compare(webView.title, "New Title") + } + + function test_javascriptDisabled() { + webView.experimental.preferences.javascriptEnabled = false + var testUrl = Qt.resolvedUrl("../common/javascript.html") + webView.load(testUrl) + spy.wait() + compare(webView.title, "Original Title") + } + + function test_localStorageDisabled() { + webView.experimental.preferences.localStorageEnabled = false + var testUrl = Qt.resolvedUrl("../common/localStorage.html") + webView.load(testUrl) + spy.wait() + compare(webView.title, "Original Title") + } + + function test_localStorageEnabled() { + webView.experimental.preferences.localStorageEnabled = true + var testUrl = Qt.resolvedUrl("../common/localStorage.html") + webView.load(testUrl) + spy.wait() + spy.clear() + webView.load(testUrl) + spy.wait() + compare(webView.title, "New Title") + } + + function test_preferencesAffectCurrentViewOnly() { + webView.experimental.preferences.javascriptEnabled = true + webView2.experimental.preferences.javascriptEnabled = true + var testUrl = Qt.resolvedUrl("../common/javascript.html") + webView.load(testUrl) + spy.wait() + webView2.load(testUrl) + otherSpy.wait() + compare(webView.title, "New Title") + compare(webView2.title, "New Title") + spy.clear() + otherSpy.clear() + webView.experimental.preferences.javascriptEnabled = false + webView.load(testUrl) + spy.wait() + webView2.load(testUrl) + otherSpy.wait() + compare(webView.title, "Original Title") + compare(webView2.title, "New Title") + } + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml new file mode 100644 index 000000000..4761cd322 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + TestCase { + name: "WebViewProperties" + + function test_title() { + compare(spy.count, 0) + webView.load(Qt.resolvedUrl("../common/test1.html")) + spy.wait() + compare(webView.title, "Test page 1") + } + + function test_url() { + compare(spy.count, 1) + var testUrl = Qt.resolvedUrl("../common/test1.html") + webView.load(testUrl) + spy.wait() + compare(webView.url, testUrl) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml new file mode 100644 index 000000000..f36ea8579 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 + +WebView { + id: webView + width: 400 + height: 300 + + SignalSpy { + id: spy + target: webView + signalName: "loadSucceeded" + } + + SignalSpy { + id: spyTitle + target: webView + signalName: "titleChanged" + } + + TestCase { + name: "WebViewTitleChangedSignal" + + function test_titleFirstLoad() { + compare(spyTitle.count, 0) + var testUrl = Qt.resolvedUrl("../common/test3.html") + webView.load(testUrl) + spyTitle.wait() + compare(webView.title, "Test page 3") + spyTitle.wait() + compare(webView.title, "New Title") + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html new file mode 100644 index 000000000..a75b9a60f --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html @@ -0,0 +1,8 @@ +<!doctype html> +<html> +<head> +<script>alert("Hello Qt");</script> +</head> +<body> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html new file mode 100644 index 000000000..5dd6081d4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html @@ -0,0 +1,19 @@ +<!doctype html> +<html> +<head> +<script> +document.title = ""; +function updateTitle(accepted) { + if (accepted) + document.title += " ACCEPTED"; + else + document.title += " REJECTED"; +} + +updateTitle(confirm("ACCEPT")); +updateTitle(confirm("REJECT")); +</script> +</head> +<body> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zip b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zip Binary files differnew file mode 100644 index 000000000..b5456351a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zip diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html new file mode 100644 index 000000000..c9f225c52 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html @@ -0,0 +1,10 @@ +<html> +<head> +</head> +<link type="image/png" href="favicon.png" sizes="48x48" rel="icon" /> +<body> +<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p> +<p>The favicon looks like this:</p> +<img src="favicon.png"/> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png Binary files differnew file mode 100644 index 000000000..35717cca5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html new file mode 100644 index 000000000..5548b867f --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html @@ -0,0 +1,10 @@ +<html> +<head> +</head> +<link type="image/png" href="small-favicon.png" sizes="16x16" rel="icon" /> +<body> +<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p> +<p>The favicon looks like this:</p> +<img src="small-favicon.png"/> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html new file mode 100644 index 000000000..2d41cab3e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html @@ -0,0 +1,29 @@ +<head> +<title>Geolocation Permission API Test</title> +<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/> +<script> +var watchId = 0; + +function successHandler(location) { + var message = document.getElementById("message"), html = []; + html.push("<img width='256' height='256' src='http://maps.google.com/maps/api/staticmap?center=", location.coords.latitude, ",", location.coords.longitude, "&markers=size:small|color:blue|", location.coords.latitude, ",", location.coords.longitude, "&zoom=14&size=256x256&sensor=false' />"); + html.push("<p>Longitude: ", location.coords.longitude, "</p>"); + html.push("<p>Latitude: ", location.coords.latitude, "</p>"); + html.push("<p>Accuracy: ", location.coords.accuracy, " meters</p>"); + message.innerHTML = html.join(""); +} + +function errorHandler(error) { + alert('Attempt to get location failed: ' + error.message); +} + +<!-- One shot example --> +navigator.geolocation.getCurrentPosition(successHandler, errorHandler); + +</script> +</head> +<body> +<div id="message">Location unknown</div> +</body> +</html> + diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html new file mode 100644 index 000000000..7a3dc0a1c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html @@ -0,0 +1,8 @@ +<html> +<head><title>Original Title</title></head> +<body> +<script type="text/javascript"> +document.title = "New Title"; +</script> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html new file mode 100644 index 000000000..a4e395f48 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html @@ -0,0 +1,9 @@ +<html> +<head><title>Original Title</title></head> +<body> +<script type="text/javascript"> +document.title = localStorage.getItem('title'); +localStorage.setItem('title', 'New Title'); +</script> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html new file mode 100644 index 000000000..7e3dd7230 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html @@ -0,0 +1,15 @@ +<!doctype html> +<html> +<head> +<script> + function initialize() { + navigator.qt.onmessage = function(ev) { + var reversed = ev.data.split("").reverse().join(""); + navigator.qt.postMessage(reversed); + } + } +</script> +</head> +<body onload="initialize();"> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html new file mode 100644 index 000000000..f35e30204 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html @@ -0,0 +1,13 @@ +<!doctype html> +<html> +<head> +<script> +document.title = prompt("Please, reverse the default value", "Hello Qt"); +if (prompt("REJECT") !== null) { + document.title = "FAIL"; +} +</script> +</head> +<body> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html new file mode 100644 index 000000000..46080f6e4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html> +<head> +<title>No new selection was made</title> +<script> +function updateTitle(selectElement) { + var index = selectElement.selectedIndex; + document.title = selectElement.options[index].value; +} +</script> +</head> +<body> +<select onchange="updateTitle(this)"> +<option value="__open__" >Open</option> +<option value="__closed__" >Closed</option> +<option value="__all__" >All</option> +</select> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.png b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.png Binary files differnew file mode 100644 index 000000000..4462752a5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.png diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html new file mode 100644 index 000000000..5c09f06ed --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html @@ -0,0 +1,6 @@ +<html> +<head><title>Test page 1</title></head> +<body> +Hello. +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html new file mode 100644 index 000000000..629c2a063 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html @@ -0,0 +1,6 @@ +<html> +<head><title>Test page with huge link area</title></head> +<body> +<a title="A title" href="test1.html"><img width=200 height=200></a> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html new file mode 100644 index 000000000..0c0e4eebf --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html @@ -0,0 +1,18 @@ +<html> +<head> +<title>Test page 3</title> +</head> +<script type="text/javascript"> +function kickOffTitleChange() +{ + var t = setTimeout("changeTitle('New Title')",3000); +} +function changeTitle(title) +{ + document.title = title; +} +</script> +<body onload="kickOffTitleChange()"> +Hello. +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro new file mode 100644 index 000000000..7e449a224 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro @@ -0,0 +1,31 @@ +include(../tests.pri) + +CONFIG += qtwebkit-private +CONFIG += warn_on testcase + +QT -= testlib +QT += qmltest + +# QML files tested are the ones in WebKit source repository. +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" + +OTHER_FILES += \ + DesktopBehavior/DesktopWebView.qml \ + DesktopBehavior/tst_linkHovered.qml \ + DesktopBehavior/tst_loadHtml.qml \ + DesktopBehavior/tst_messaging.qml \ + DesktopBehavior/tst_navigationRequested.qml \ + WebView/tst_favIconLoad.qml \ + WebView/tst_download.qml \ + WebView/tst_geopermission.qml \ + WebView/tst_itemSelector.qml \ + WebView/tst_javaScriptDialogs.qml \ + WebView/tst_loadFail.qml \ + WebView/tst_loadHtml.qml \ + WebView/tst_loadProgress.qml \ + WebView/tst_loadProgressSignal.qml \ + WebView/tst_preferences.qml \ + WebView/tst_properties.qml \ + WebView/tst_titleChanged.qml \ + WebView/tst_applicationScheme.qml diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp new file mode 100644 index 000000000..e8d9aab0e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp @@ -0,0 +1,45 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "../util.h" + +#include <QVarLengthArray> +#include <QtQuickTest/quicktest.h> +#include <QtWidgets/QApplication> + +int main(int argc, char** argv) +{ + QVarLengthArray<char*, 8> arguments; + for (int i = 0; i < argc; ++i) + arguments.append(argv[i]); + + arguments.append(const_cast<char*>("-import")); + arguments.append(const_cast<char*>(IMPORT_DIR)); + + argc = arguments.count(); + argv = arguments.data(); + + suppressDebugOutput(); + addQtWebProcessToPath(); + + // Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication. + // This can be removed as soon as we do not use QtWidgets any more. + QApplication app(argc, argv); + return quick_test_main(argc, argv, "qmltests", 0, QUICK_TEST_SOURCE_DIR); +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro new file mode 100644 index 000000000..728521f8a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro @@ -0,0 +1,2 @@ +include(../tests.pri) +CONFIG += qtwebkit-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp new file mode 100644 index 000000000..57b7ec14a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp @@ -0,0 +1,290 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "../testwindow.h" +#include "../util.h" + +#include <QScopedPointer> +#include <QtTest/QtTest> +#include <qquickwebpage_p.h> +#include <qquickwebview_p.h> + +class tst_QQuickWebView : public QObject { + Q_OBJECT +public: + tst_QQuickWebView(); + +private slots: + void init(); + void cleanup(); + + void accessPage(); + void navigationStatusAtStartup(); + void stopEnabledAfterLoadStarted(); + void baseUrl(); + void loadEmptyUrl(); + void loadEmptyPageViewVisible(); + void loadEmptyPageViewHidden(); + void loadNonexistentFileUrl(); + void backAndForward(); + void reload(); + void stop(); + void loadProgress(); + void scrollRequest(); + + void show(); + void showWebView(); + void removeFromCanvas(); + +private: + inline QQuickWebView* webView() const; + QScopedPointer<TestWindow> m_window; +}; + +tst_QQuickWebView::tst_QQuickWebView() +{ + addQtWebProcessToPath(); + qRegisterMetaType<QQuickWebPage*>("QQuickWebPage*"); +} + +void tst_QQuickWebView::init() +{ + m_window.reset(new TestWindow(new QQuickWebView())); +} + +void tst_QQuickWebView::cleanup() +{ + m_window.reset(); +} + +inline QQuickWebView* tst_QQuickWebView::webView() const +{ + return static_cast<QQuickWebView*>(m_window->webView.data()); +} + +void tst_QQuickWebView::accessPage() +{ + QQuickWebPage* const pageDirectAccess = webView()->page(); + + QVariant pagePropertyValue = webView()->experimental()->property("page"); + QQuickWebPage* const pagePropertyAccess = pagePropertyValue.value<QQuickWebPage*>(); + QCOMPARE(pagePropertyAccess, pageDirectAccess); +} + +void tst_QQuickWebView::navigationStatusAtStartup() +{ + QCOMPARE(webView()->canGoBack(), false); + + QCOMPARE(webView()->canGoForward(), false); + + QCOMPARE(webView()->loading(), false); + + QCOMPARE(webView()->canReload(), false); +} + +class LoadStartedCatcher : public QObject { + Q_OBJECT +public: + LoadStartedCatcher(QQuickWebView* webView) + : m_webView(webView) + { + connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); + } + +public slots: + void onLoadStarted() + { + QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); + + QCOMPARE(m_webView->loading(), true); + } + +signals: + void finished(); + +private: + QQuickWebView* m_webView; +}; + +void tst_QQuickWebView::stopEnabledAfterLoadStarted() +{ + QCOMPARE(webView()->loading(), false); + + LoadStartedCatcher catcher(webView()); + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); + waitForSignal(&catcher, SIGNAL(finished())); + + QCOMPARE(webView()->loading(), true); + + waitForSignal(webView(), SIGNAL(loadSucceeded())); +} + +void tst_QQuickWebView::baseUrl() +{ + // Test the url is in a well defined state when instanciating the view, but before loading anything. + QVERIFY(webView()->url().isEmpty()); +} + +void tst_QQuickWebView::loadEmptyUrl() +{ + webView()->load(QUrl()); + webView()->load(QUrl(QLatin1String(""))); +} + +void tst_QQuickWebView::loadEmptyPageViewVisible() +{ + m_window->show(); + loadEmptyPageViewHidden(); +} + +void tst_QQuickWebView::loadEmptyPageViewHidden() +{ + QSignalSpy loadStartedSpy(webView(), SIGNAL(loadStarted())); + + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(loadStartedSpy.size(), 1); +} + +void tst_QQuickWebView::loadNonexistentFileUrl() +{ + QSignalSpy loadFailedSpy(webView(), SIGNAL(loadStarted())); + + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/file_that_does_not_exist.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadFailed(QQuickWebView::ErrorDomain, int, QUrl, QString)))); + + QCOMPARE(loadFailedSpy.size(), 1); +} + +void tst_QQuickWebView::backAndForward() +{ + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")); + + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html")); + + webView()->goBack(); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")); + + webView()->goForward(); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html")); +} + +void tst_QQuickWebView::reload() +{ + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")); + + webView()->reload(); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")); +} + +void tst_QQuickWebView::stop() +{ + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")); + + // FIXME: This test should be fleshed out. Right now it's just here to make sure we don't crash. + webView()->stop(); +} + +void tst_QQuickWebView::loadProgress() +{ + QCOMPARE(webView()->loadProgress(), 0); + + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); + QSignalSpy loadProgressChangedSpy(webView(), SIGNAL(loadProgressChanged(int))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + QVERIFY(loadProgressChangedSpy.count() >= 1); + + QCOMPARE(webView()->loadProgress(), 100); +} + +void tst_QQuickWebView::show() +{ + // This should not crash. + m_window->show(); + QTest::qWait(200); + m_window->hide(); +} + +void tst_QQuickWebView::showWebView() +{ + webView()->setSize(QSizeF(300, 400)); + + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/direct-image-compositing.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + m_window->show(); + // This should not crash. + webView()->setVisible(true); + QTest::qWait(200); + webView()->setVisible(false); + QTest::qWait(200); +} + +void tst_QQuickWebView::removeFromCanvas() +{ + showWebView(); + + // This should not crash. + QQuickItem* parent = webView()->parentItem(); + QQuickItem noCanvasItem; + webView()->setParentItem(&noCanvasItem); + QTest::qWait(200); + webView()->setParentItem(parent); + webView()->setVisible(true); + QTest::qWait(200); +} + +void tst_QQuickWebView::scrollRequest() +{ + webView()->setSize(QSizeF(300, 400)); + + webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html"))); + QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded()))); + + // COMPARE with the position requested in the html + // Use qRound as that is also used when calculating the position + // in WebKit. + int y = -qRound(50 * webView()->page()->scale()); + QVERIFY(webView()->page()->pos().y() == y); +} + +QTWEBKIT_API_TEST_MAIN(tst_QQuickWebView) + +#include "tst_qquickwebview.moc" + diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri new file mode 100644 index 000000000..297bcec92 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri @@ -0,0 +1,15 @@ +TEMPLATE = app + +VPATH += $$_PRO_FILE_PWD_ +TARGET = tst_$$TARGET + +SOURCES += $${TARGET}.cpp \ + ../util.cpp +INCLUDEPATH += $$PWD + +QT += testlib declarative widgets + +CONFIG += qtwebkit + +DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\" \ + QWP_PATH=\\\"$${ROOT_BUILD_DIR}/bin\\\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h new file mode 100644 index 000000000..1eaa43772 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef testwindow_h +#define testwindow_h + +#include <QResizeEvent> +#include <QScopedPointer> +#include <QtQuick/qquickitem.h> +#include <QtQuick/qquickview.h> + +// TestWindow: Utility class to ignore QQuickView details. +class TestWindow : public QQuickView { +public: + inline TestWindow(QQuickItem* webView); + QScopedPointer<QQuickItem> webView; + +protected: + inline void resizeEvent(QResizeEvent*); +}; + +inline TestWindow::TestWindow(QQuickItem* webView) + : webView(webView) +{ + Q_ASSERT(webView); + webView->setParentItem(rootItem()); +} + +inline void TestWindow::resizeEvent(QResizeEvent* event) +{ + QQuickView::resizeEvent(event); + webView->setX(0); + webView->setY(0); + webView->setWidth(event->size().width()); + webView->setHeight(event->size().height()); +} + +#endif /* testwindow_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.cpp b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp new file mode 100644 index 000000000..e230221e6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp @@ -0,0 +1,67 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "util.h" +#include <stdio.h> + +void addQtWebProcessToPath() +{ + // Since tests won't find ./QtWebProcess, add it to PATH (at the end to prevent surprises). + // QWP_PATH should be defined by qmake. + qputenv("PATH", qgetenv("PATH") + ":" + QWP_PATH); +} + +/** + * Starts an event loop that runs until the given signal is received. + * Optionally the event loop + * can return earlier on a timeout. + * + * \return \p true if the requested signal was received + * \p false on timeout + */ +bool waitForSignal(QObject* obj, const char* signal, int timeout) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} + +static void messageHandler(QtMsgType type, const char* message) +{ + if (type == QtCriticalMsg) { + fprintf(stderr, "%s\n", message); + return; + } + // Do nothing +} + +void suppressDebugOutput() +{ + qInstallMsgHandler(messageHandler); \ + if (qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT").isEmpty()) \ + qputenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT", "1"); +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.h b/Source/WebKit2/UIProcess/API/qt/tests/util.h new file mode 100644 index 000000000..007964fe5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/util.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +// Functions and macros that really need to be in QTestLib + +#include <QEventLoop> +#include <QSignalSpy> +#include <QTimer> + +#if !defined(TESTS_SOURCE_DIR) +#define TESTS_SOURCE_DIR "" +#endif + +void addQtWebProcessToPath(); +bool waitForSignal(QObject*, const char* signal, int timeout = 10000); +void suppressDebugOutput(); + +#define QTWEBKIT_API_TEST_MAIN(TestObject) \ +int main(int argc, char** argv) \ +{ \ + suppressDebugOutput(); \ + QApplication app(argc, argv); \ + QTEST_DISABLE_KEYPAD_NAVIGATION \ + TestObject tc; \ + return QTest::qExec(&tc, argc, argv); \ +} |