Changeset 102959 in webkit


Ignore:
Timestamp:
Dec 15, 2011 10:39:51 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt][WK2] Add test for download policy on navigation request
https://bugs.webkit.org/show_bug.cgi?id=74541

Patch by Rafael Brandao <rafael.lobo@openbossa.org> on 2011-12-15
Reviewed by Tor Arne Vestbø.

  • UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml:
  • UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml: Make it wait for a

downloadFinished signal to finish the test.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r102954 r102959  
     12011-12-15  Rafael Brandao  <rafael.lobo@openbossa.org>
     2
     3        [Qt][WK2] Add test for download policy on navigation request
     4        https://bugs.webkit.org/show_bug.cgi?id=74541
     5
     6        Reviewed by Tor Arne Vestbø.
     7
     8        * UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml:
     9        * UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml: Make it wait for a
     10        downloadFinished signal to finish the test.
     11
    1122011-12-15  Anders Carlsson  <andersca@apple.com>
    213
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml

    r101162 r102959  
    44
    55Item {
     6    property int expectedLength: 0
     7    property int totalBytes: 0
     8    property bool shouldDownload: false
     9
    610    DesktopWebView {
    711        id: webView
    812        width: 200
    913        height: 200
     14
     15        signal downloadFinished()
     16
    1017        onNavigationRequested: {
    11             if (request.button == Qt.MiddleButton && request.modifiers & Qt.ControlModifier) {
     18            if (shouldDownload)
     19                request.action = WebView.DownloadRequest
     20            else if (request.button == Qt.MiddleButton && request.modifiers & Qt.ControlModifier) {
    1221                otherWebView.load(request.url)
    1322                request.action = WebView.IgnoreRequest
     23            }
     24        }
     25
     26        experimental.onDownloadRequested: {
     27            download.target = downloadItem
     28            expectedLength = downloadItem.expectedContentLength
     29            downloadItem.destinationPath = downloadItem.suggestedFilename
     30            downloadItem.start()
     31        }
     32
     33        Connections {
     34            id: download
     35            ignoreUnknownSignals: true
     36            onSucceeded: {
     37                totalBytes = download.target.totalBytesReceived
     38                webView.downloadFinished()
    1439            }
    1540        }
     
    3257    }
    3358
     59    SignalSpy {
     60        id: downloadSpy
     61        target: webView.experimental
     62        signalName: "downloadRequested"
     63    }
     64
     65    SignalSpy {
     66        id: downloadFinishedSpy
     67        target: webView
     68        signalName: "downloadFinished"
     69    }
     70
    3471    TestCase {
    3572        name: "DesktopWebViewNavigationRequested"
     
    4279            interval: 1
    4380            onTriggered: parent.when = true
     81        }
     82
     83        function init() {
     84            spy.clear()
     85            otherSpy.clear()
     86            downloadSpy.clear()
     87            downloadFinishedSpy.clear()
     88            shouldDownload = false
    4489        }
    4590
     
    66111            compare(otherWebView.title, "Test page 1")
    67112        }
     113
     114        function test_downloadPolicy() {
     115            webView.load(Qt.resolvedUrl("../common/test2.html"))
     116            spy.wait()
     117            spy.clear()
     118            compare(spy.count, 0)
     119            downloadSpy.clear()
     120            downloadFinishedSpy.clear()
     121            expectedLength = 0
     122            shouldDownload = true
     123            mouseClick(webView, 100, 100, Qt.LeftButton)
     124            downloadSpy.wait()
     125            compare(downloadSpy.count, 1)
     126            downloadFinishedSpy.wait()
     127            compare(downloadFinishedSpy.count, 1)
     128            compare(totalBytes, expectedLength)
     129        }
    68130    }
    69131}
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml

    r101103 r102959  
    1010
    1111    property int expectedLength: 0
    12     property bool downloadFinished: false
    1312    property int totalBytes: 0
     13
     14    signal downloadFinished()
    1415
    1516    SignalSpy {
     
    1718        target: experimental
    1819        signalName: "downloadRequested"
     20    }
     21
     22    SignalSpy {
     23        id: downloadFinishedSpy
     24        target: webView
     25        signalName: "downloadFinished"
    1926    }
    2027
     
    3037        ignoreUnknownSignals: true
    3138        onSucceeded: {
    32             downloadFinished = true
    3339            totalBytes = download.target.totalBytesReceived
     40            webView.downloadFinished()
    3441        }
    3542    }
     
    4956        function init() {
    5057            spy.clear()
     58            downloadFinishedSpy.clear()
    5159            expectedLength = 0
    52             downloadFinished = false
    5360        }
    5461
     
    7380            spy.wait()
    7481            compare(spy.count, 1)
    75             verify(downloadFinished)
     82            downloadFinishedSpy.wait()
    7683            compare(totalBytes, expectedLength)
    7784        }
Note: See TracChangeset for help on using the changeset viewer.