Add QML API tests for Device Pixel Ratio
authorahf@0x90.dk <ahf@0x90.dk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2012 14:46:21 +0000 (14:46 +0000)
committerahf@0x90.dk <ahf@0x90.dk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2012 14:46:21 +0000 (14:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88531

Reviewed by Kenneth Rohde Christiansen.

This patch adds an initial test case for the QML device pixel ratio
API. The test currently fails and is therefore marked as being
expected to fail. This will be fixed in a separated patch.

* UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml: Added.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml [new file with mode: 0644]

index 91d68d0..7a3602c 100644 (file)
@@ -1,3 +1,16 @@
+2012-06-07  Alexander Færøy  <ahf@0x90.dk>
+
+        Add QML API tests for Device Pixel Ratio
+        https://bugs.webkit.org/show_bug.cgi?id=88531
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch adds an initial test case for the QML device pixel ratio
+        API. The test currently fails and is therefore marked as being
+        expected to fail. This will be fixed in a separated patch.
+
+        * UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml: Added.
+
 2012-06-07  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL][WK2] WebKit2-EFL does not link in debug mode
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml
new file mode 100644 (file)
index 0000000..643c721
--- /dev/null
@@ -0,0 +1,63 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+import "../common"
+
+Item {
+    TestWebView {
+        id: webView
+        property variant lastResult
+    }
+
+    SignalSpy {
+        id: resultSpy
+        target: webView
+        signalName: "lastResultChanged"
+    }
+
+    TestCase {
+        name: "DevicePixelRatio"
+
+        function init() {
+            resultSpy.clear()
+            webView.lastResult = null
+        }
+
+        function test_devicePixelRatio() {
+            expectFail("", "This currently fails since window.devicePixelRatio doesn't return the updated value.")
+
+            resultSpy.clear()
+            webView.url = "about:blank"
+            webView.experimental.devicePixelRatio = 2.0
+            verify(webView.waitForLoadSucceeded())
+
+            webView.experimental.evaluateJavaScript(
+                "(function() { return window.devicePixelRatio })()",
+                function(result) {
+                    webView.lastResult = result
+                })
+
+            resultSpy.wait()
+            compare(webView.lastResult, 2.0)
+            compare(webView.lastResult, webView.experimental.devicePixelRatio)
+        }
+
+        function test_devicePixelRatioMediaQuery() {
+            expectFail("", "This currently fails since the devicePixelRatio from the QML API isn't propagated correctly.")
+            resultSpy.clear()
+            webView.url = "about:blank"
+            webView.experimental.devicePixelRatio = 2.0
+            verify(webView.waitForLoadSucceeded())
+
+            webView.experimental.evaluateJavaScript(
+                "(function() { return window.matchMedia('-webkit-device-pixel-ratio: 2').matches })()",
+                function(result) {
+                    webView.lastResult = result
+                })
+
+            resultSpy.wait()
+            verify(webView.lastResult)
+        }
+    }
+}