[Qt][WK2] Export QNetworkReply in the QtWebKit QML module.
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2011 16:08:20 +0000 (16:08 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2011 16:08:20 +0000 (16:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68401

Reviewed by Simon Hausmann.

Add QNetworkReply in the QtWebKit module. We use the enum QNetworkReply::NetworkError
as the error code when the load fails. It is not used in the QtQuick module therefore
the QML team thinks it should belong here. Also added some auto-tests to cover the
loading errors.

* UIProcess/API/qt/qmlplugin/plugin.cpp:
(WebKit2QmlPlugin::registerTypes):
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml: Added.
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@95545 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml [new file with mode: 0644]

index c29d0b5..95bbddb 100644 (file)
@@ -1,3 +1,20 @@
+2011-09-20  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt][WK2] Export QNetworkReply in the QtWebKit QML module.
+        https://bugs.webkit.org/show_bug.cgi?id=68401
+
+        Reviewed by Simon Hausmann.
+
+        Add QNetworkReply in the QtWebKit module. We use the enum QNetworkReply::NetworkError
+        as the error code when the load fails. It is not used in the QtQuick module therefore
+        the QML team thinks it should belong here. Also added some auto-tests to cover the
+        loading errors.
+
+        * UIProcess/API/qt/qmlplugin/plugin.cpp:
+        (WebKit2QmlPlugin::registerTypes):
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml: Added.
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml: Added.
+
 2011-09-20  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt][Mac] Buildfix after r95513.
index 4bdf42c..85d7d08 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <QtDeclarative/qdeclarative.h>
 #include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtNetwork/qnetworkreply.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -37,6 +38,7 @@ public:
         qmlRegisterType<QTouchWebView>(uri, 5, 0, "TouchWebView");
         qmlRegisterUncreatableType<QWebNavigationController>(uri, 5, 0, "NavigationController", QObject::tr("Cannot create separate instance of NavigationController"));
         qmlRegisterUncreatableType<QTouchWebPage>(uri, 5, 0, "TouchWebPage", QObject::tr("Cannot create separate instance of TouchWebPage, use TouchWebView"));
+        qmlRegisterUncreatableType<QNetworkReply>(uri, 5, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
     }
 };
 
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml
new file mode 100644 (file)
index 0000000..936f2a3
--- /dev/null
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit.experimental 5.0
+
+DesktopWebView {
+    id: webView
+
+    property variant testUrl
+
+    SignalSpy {
+        id: spy
+        target: webView
+        signalName: "loadFailed"
+    }
+
+    TestCase {
+        id: test
+        name: "DesktopWebViewLoadFail"
+        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(errorType, DesktopWebView.NetworkError)
+    }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml
new file mode 100644 (file)
index 0000000..3258384
--- /dev/null
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit.experimental 5.0
+
+TouchWebView {
+    id: webView
+
+    property variant testUrl
+
+    SignalSpy {
+        id: spy
+        target: webView.page
+        signalName: "loadFailed"
+    }
+
+    TestCase {
+        id: test
+        name: "TouchWebViewLoadFail"
+
+        function test_fail() {
+            skip("Fails due to https://bugreports.qt.nokia.com/browse/QTBUG-21537")
+            compare(spy.count, 0)
+            testUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
+            webView.page.load(testUrl)
+            spy.wait()
+            compare(spy.count, 1)
+        }
+    }
+    Connections {
+        target: webView.page
+        onLoadFailed: {
+            test.compare(url, testUrl)
+            test.compare(errorCode, NetworkReply.ContentNotFoundError)
+            test.compare(errorType, TouchWebPage.NetworkError)
+        }
+    }
+}