diff options
author | Adam Kallai <kadam@inf.u-szeged.hu> | 2014-04-07 07:42:39 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-09 11:43:51 +0200 |
commit | a0569a3c26b64782d1bdf39e3b45641659b2bc14 (patch) | |
tree | 60139177832d72b8ab989b0464127beafe1c093c /tests/auto/quick/qmltests | |
parent | 8e5d985e8db8e3f22bc25bbb0363451b7b9d2c91 (diff) |
Add test_urlProperty to tst_loadUrl.qml testcase.
Change-Id: Ia6b866ed52511b92cf7a176f9018c24a31c2ffc0
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'tests/auto/quick/qmltests')
-rw-r--r-- | tests/auto/quick/qmltests/data/link.html | 6 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/redirect.html | 8 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_loadUrl.qml | 81 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/qmltests.pro | 2 |
4 files changed, 93 insertions, 4 deletions
diff --git a/tests/auto/quick/qmltests/data/link.html b/tests/auto/quick/qmltests/data/link.html new file mode 100644 index 000000000..e791b7de4 --- /dev/null +++ b/tests/auto/quick/qmltests/data/link.html @@ -0,0 +1,6 @@ +<!doctype html> +<html> +<body onload="document.links['foo'].focus();"> +<a name="foo" href="test1.html">Link</a> +</body> +</html> diff --git a/tests/auto/quick/qmltests/data/redirect.html b/tests/auto/quick/qmltests/data/redirect.html new file mode 100644 index 000000000..914e5e35a --- /dev/null +++ b/tests/auto/quick/qmltests/data/redirect.html @@ -0,0 +1,8 @@ +<!doctype html> +<html> +<head> +<meta http-equiv="refresh" content="2; url=test1.html" +</head> +<body> +</body> +</html> diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml index 9723052de..796e7416d 100644 --- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml +++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml @@ -48,10 +48,13 @@ TestWebEngineView { width: 400 height: 300 + property var lastUrl property bool watchProgress: false property int numLoadStarted: 0 property int numLoadSucceeded: 0 + focus: true + onLoadProgressChanged: { if (watchProgress && webEngineView.loadProgress != 100) { watchProgress = false @@ -68,6 +71,7 @@ TestWebEngineView { TestCase { name: "WebEngineViewLoadUrl" + when: windowShown function test_loadIgnoreEmptyUrl() { var url = Qt.resolvedUrl("test1.html") @@ -78,7 +82,7 @@ TestWebEngineView { compare(numLoadSucceeded, 1) compare(webEngineView.url, url) - var lastUrl = webEngineView.url + lastUrl = webEngineView.url webEngineView.url = '' wait(1000) compare(numLoadStarted, 1) @@ -101,21 +105,90 @@ TestWebEngineView { compare(webEngineView.url, url) } + function test_urlProperty() { + var url = Qt.resolvedUrl("test1.html") + + webEngineView.url = url + compare(webEngineView.url, url) + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.url, url) + + var bogusSite = "http://www.somesitethatdoesnotexist.abc/" + webEngineView.url = bogusSite + compare(webEngineView.url, bogusSite) + verify(webEngineView.waitForLoadFailed()) + compare(webEngineView.url, bogusSite) + + webEngineView.url = "about:blank" // Reset from previous test + verify(webEngineView.waitForLoadSucceeded()) + + var handleLoadFailed = function(loadRequest) { + if (loadRequest.status == WebEngineView.LoadFailedStatus) { + compare(webEngineView.url, bogusSite) + compare(loadRequest.url, bogusSite) + webEngineView.loadHtml("load failed", bogusSite, bogusSite) + } + } + webEngineView.loadingChanged.connect(handleLoadFailed) + webEngineView.url = bogusSite + compare(webEngineView.url, bogusSite) + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.url, bogusSite) + webEngineView.loadingChanged.disconnect(handleLoadFailed) + + var dataUrl = "data:text/html,foo" + webEngineView.url = dataUrl + compare(webEngineView.url, dataUrl) + + var redirectUrl = Qt.resolvedUrl("redirect.html") + webEngineView.url = redirectUrl + compare(webEngineView.url, redirectUrl) + verify(webEngineView.waitForLoadSucceeded()) // redirect.html is loaded + compare(webEngineView.url, redirectUrl) + verify(webEngineView.waitForLoadSucceeded()) // test1.html is loaded + compare(webEngineView.url, url) + + var linkUrl = Qt.resolvedUrl("link.html") + webEngineView.url = linkUrl + compare(webEngineView.url, linkUrl) + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.url, linkUrl) + + var handleLoadRequest = function(loadRequest) { + if (loadRequest.status == WebEngineView.LoadStartedStatus) { + compare(webEngineView.url, lastUrl) + compare(loadRequest.url, url) + } + if (loadRequest.status == WebEngineView.LoadSuceededStatus) { + compare(webEngineView.url, loadRequest.url) + compare(webEngineView.url, url) + } + } + lastUrl = webEngineView.url + webEngineView.loadingChanged.connect(handleLoadRequest) + webEngineView.forceActiveFocus() + keyPress(Qt.Key_Return) // Link is focused + verify(webEngineView.waitForLoadSucceeded()) + compare(webEngineView.url, url) + webEngineView.loadingChanged.disconnect(handleLoadRequest) + } + function test_stopStatus() { var url = Qt.resolvedUrl("test1.html") - webEngineView.loadingChanged.connect(function(loadRequest) { + var handleLoadRequest = function(loadRequest) { if (loadRequest.status == WebEngineView.LoadStoppedStatus) { compare(webEngineView.url, url) compare(loadRequest.url, url) } - }) - + } + webEngineView.loadingChanged.connect(handleLoadRequest) webEngineView.url = url compare(webEngineView.url, url) webEngineView.stop() verify(webEngineView.waitForLoadStopped()) compare(webEngineView.url, url) + webEngineView.loadingChanged.disconnect(handleLoadRequest) } } } diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index e4b6e9b22..380abd709 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -11,6 +11,8 @@ OTHER_FILES += \ $$PWD/data/favicon.html \ $$PWD/data/favicon.png \ $$PWD/data/favicon2.html \ + $$PWD/data/link.html \ + $$PWD/data/redirect.html \ $$PWD/data/small-favicon.png \ $$PWD/data/test1.html \ $$PWD/data/test3.html \ |