Title: [120916] trunk/Source/WebKit2
- Revision
- 120916
- Author
- [email protected]
- Date
- 2012-06-21 04:38:06 -0700 (Thu, 21 Jun 2012)
Log Message
[Qt] API tests for ColorChooser
https://bugs.webkit.org/show_bug.cgi?id=88101
Patch by Thiago Marcos P. Santos <[email protected]> on 2012-06-21
Reviewed by Kenneth Rohde Christiansen.
The test uses the value sanitization to detect if the feature is
enabled or disabled and will just pass when disabled.
* UIProcess/API/qt/tests/qmltests/WebView/tst_colorChooser.qml: Added.
* UIProcess/API/qt/tests/qmltests/common/colorChooser.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (120915 => 120916)
--- trunk/Source/WebKit2/ChangeLog 2012-06-21 10:58:53 UTC (rev 120915)
+++ trunk/Source/WebKit2/ChangeLog 2012-06-21 11:38:06 UTC (rev 120916)
@@ -1,5 +1,18 @@
2012-06-21 Thiago Marcos P. Santos <[email protected]>
+ [Qt] API tests for ColorChooser
+ https://bugs.webkit.org/show_bug.cgi?id=88101
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The test uses the value sanitization to detect if the feature is
+ enabled or disabled and will just pass when disabled.
+
+ * UIProcess/API/qt/tests/qmltests/WebView/tst_colorChooser.qml: Added.
+ * UIProcess/API/qt/tests/qmltests/common/colorChooser.html: Added.
+
+2012-06-21 Thiago Marcos P. Santos <[email protected]>
+
[WK2][Qt] Color chooser API missing
https://bugs.webkit.org/show_bug.cgi?id=87749
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_colorChooser.qml (0 => 120916)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_colorChooser.qml (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_colorChooser.qml 2012-06-21 11:38:06 UTC (rev 120916)
@@ -0,0 +1,94 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+import "../common"
+
+TestWebView {
+ id: webView
+
+ width: 400
+ height: 400
+
+ property bool featureEnabled
+
+ property string selectedColor
+ property bool shouldReject
+ property bool shouldAcceptCurrent
+
+ experimental.colorChooser: Item {
+ Component.onCompleted: {
+ if (WebView.view.shouldReject)
+ model.reject()
+ else if (WebView.view.shouldAcceptCurrent)
+ model.accept(model.currentColor)
+ else
+ model.accept(WebView.view.selectedColor)
+ }
+ }
+
+ function openColorChooser() {
+ webView.experimental.test.touchTap(webView, 25, 25)
+ }
+
+ SignalSpy {
+ id: titleSpy
+ target: webView
+ signalName: "titleChanged"
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewColorChooser"
+ when: windowShown
+
+ function init() {
+ webView.url = ""
+ verify(webView.waitForLoadSucceeded())
+
+ webView.featureEnabled = (webView.title == "Feature enabled")
+
+ titleSpy.clear()
+
+ webView.shouldReject = false;
+ webView.shouldAcceptCurrent = false;
+ }
+
+ function test_accept() {
+ if (!webView.featureEnabled)
+ return
+
+ // The title changes here twice: first
+ // when we click, it changes from "Feature enabled"
+ // to the sanitized color and next, when we
+ // pick a new color with the chooser.
+ webView.selectedColor = "#020020"
+ openColorChooser()
+ titleSpy.wait()
+ compare(titleSpy.count, 2)
+ compare(webView.title, "#020020")
+ }
+
+ function test_currentValue() {
+ if (!webView.featureEnabled)
+ return
+
+ webView.shouldAcceptCurrent = true
+ openColorChooser()
+ titleSpy.wait()
+ compare(titleSpy.count, 1)
+ compare(webView.title, "#000000")
+ }
+
+ function test_reject() {
+ if (!webView.featureEnabled)
+ return
+
+ webView.shouldReject = true;
+ openColorChooser()
+ titleSpy.wait()
+ compare(titleSpy.count, 1)
+ compare(webView.title, "#000000")
+ }
+ }
+}
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/colorChooser.html (0 => 120916)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/colorChooser.html (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/colorChooser.html 2012-06-21 11:38:06 UTC (rev 120916)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Feature disabled</title>
+<script>
+function detectInputTypeColorEnabled() {
+ var element = document.getElementById('test')
+ element.value = 'should sanitize';
+ if (element.value != 'should sanitize')
+ document.title = 'Feature enabled';
+}
+function updateTitle(element) {
+ document.title = element.value;
+}
+</script>
+</head>
+<body _onload_='detectInputTypeColorEnabled()'>
+<input id='test' type='color' _onclick_='updateTitle(this)' _onchange_='updateTitle(this)' style='width:50px; height:50px; position:"absolute"; top:0px; left:0px'>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes