summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-27 20:29:44 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-27 20:29:44 +0200
commitc9b2eac2912bd8f533fd190952a72cc9478e48b1 (patch)
treebbf7ab176aaccb29cb03e72ec0cc16b3321fc32d /tests
parent81b9f5c05f3ee77abcd84dfe28f51c1031699bf9 (diff)
parent9da1716d05770f6deb3af654f28024234d711eb7 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qmltests/data/tst_favicon.qml12
-rw-r--r--tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml3
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST3
-rw-r--r--tests/auto/widgets/qwebenginepage/resources/pasteimage.html30
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp31
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc1
6 files changed, 70 insertions, 10 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml
index 633859add..f8ad998ef 100644
--- a/tests/auto/quick/qmltests/data/tst_favicon.qml
+++ b/tests/auto/quick/qmltests/data/tst_favicon.qml
@@ -70,14 +70,11 @@ TestWebEngineView {
name: "WebEngineFavicon"
when: windowShown
- function init() {
- if (webEngineView.icon != '') {
- // If this is not the first test, then load a blank page without favicon, restoring the initial state.
- webEngineView.url = 'about:blank'
- verify(webEngineView.waitForLoadSucceeded())
- iconChangedSpy.wait()
- }
+ function init() {
+ // It is worth to restore the initial state with loading a blank page before all test functions.
+ webEngineView.url = 'about:blank'
+ verify(webEngineView.waitForLoadSucceeded())
iconChangedSpy.clear()
}
@@ -149,7 +146,6 @@ TestWebEngineView {
}
function test_errorPageEnabled() {
- skip("Error page does not work properly: QTBUG-48995")
WebEngine.settings.errorPageEnabled = true
compare(iconChangedSpy.count, 0)
diff --git a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
index 117df5776..73673f511 100644
--- a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
+++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
@@ -110,8 +110,7 @@ TestWebEngineView {
webEngineView.reload()
verify(webEngineView.waitForLoadSucceeded())
compare(JSDialogParams.dialogCount, 2)
- expectFail("", "QTBUG-51749")
- compare(webEngineView.title, "prompt.html")
+ compare(webEngineView.title, "null")
}
}
}
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index d4481dc3f..30b43d6b7 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -6,3 +6,6 @@ osx
[getUserMediaRequest]
windows
+
+[setHtmlWithImageResource]
+*
diff --git a/tests/auto/widgets/qwebenginepage/resources/pasteimage.html b/tests/auto/widgets/qwebenginepage/resources/pasteimage.html
new file mode 100644
index 000000000..cc37d9319
--- /dev/null
+++ b/tests/auto/widgets/qwebenginepage/resources/pasteimage.html
@@ -0,0 +1,30 @@
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <script>
+ window.onload = function() {
+ document.getElementById("pasteArea").focus();
+ }
+ document.onpaste = function(event) {
+ var items = (event.clipboardData || event.originalEvent.clipboardData).items;
+ var blob = null;
+ for (var i = 0; i < items.length; ++i) {
+ if (items[i].type.indexOf("image/png") !== -1) {
+ blob = items[i].getAsFile();
+ break;
+ }
+ }
+ if (!blob)
+ return;
+ var reader = new FileReader();
+ reader.onload = function(event) {
+ window.myImageDataURL = event.target.result;
+ }
+ reader.readAsDataURL(blob);
+ };
+ </script>
+ </head>
+ <body>
+ <textarea id="pasteArea" placeholder="paste here"></textarea>
+ </body>
+</html>
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index cc9b1838c..8c5b58e00 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -32,6 +32,7 @@
#include <QPushButton>
#include <QStateMachine>
#include <QStyle>
+#include <QtGui/QClipboard>
#include <QtTest/QtTest>
#include <QTextCharFormat>
#include <QWebChannel>
@@ -121,6 +122,7 @@ private Q_SLOTS:
void geolocationRequestJS();
void loadFinished();
void actionStates();
+ void pasteImage();
void popupFormSubmission();
void userStyleSheet();
void userStyleSheetFromLocalFileUrl();
@@ -461,6 +463,35 @@ void tst_QWebEnginePage::actionStates()
QTRY_VERIFY(!stopAction->isEnabled());
}
+static QImage imageWithoutAlpha(const QImage &image)
+{
+ QImage result = image;
+ QPainter painter(&result);
+ painter.fillRect(result.rect(), Qt::green);
+ painter.drawImage(0, 0, image);
+ return result;
+}
+
+void tst_QWebEnginePage::pasteImage()
+{
+ // Pixels with an alpha value of 0 will have different RGB values after the
+ // test -> clipboard -> webengine -> test roundtrip.
+ // Clear the alpha channel to make QCOMPARE happy.
+ const QImage origImage = imageWithoutAlpha(QImage(":/resources/image.png"));
+ QClipboard *clipboard = QGuiApplication::clipboard();
+ clipboard->setImage(origImage);
+ QWebEnginePage *page = m_view->page();
+ page->load(QUrl("qrc:///resources/pasteimage.html"));
+ QVERIFY(waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+ page->triggerAction(QWebEnginePage::Paste);
+ QTRY_VERIFY(evaluateJavaScriptSync(page,
+ "window.myImageDataURL ? window.myImageDataURL.length : 0").toInt() > 0);
+ QByteArray data = evaluateJavaScriptSync(page, "window.myImageDataURL").toByteArray();
+ data.remove(0, data.indexOf(";base64,") + 8);
+ const QImage image = QImage::fromData(QByteArray::fromBase64(data), "PNG");
+ QCOMPARE(image, origImage);
+}
+
class ConsolePage : public QWebEnginePage
{
public:
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
index c7bffd5bb..91adeb694 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
@@ -12,6 +12,7 @@
<file>resources/script.html</file>
<file>resources/user.css</file>
<file>resources/image.png</file>
+ <file>resources/pasteimage.html</file>
<file>resources/style.css</file>
<file>resources/test1.html</file>
<file>resources/test2.html</file>