From 0f51b90fd881910825f1a8584d420f5fdd7365d9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 4 Mar 2016 10:01:00 +0100 Subject: [Reapply] Blacklist getUserMediaRequest on Windows This change was lost in the last merge from 5.6, but is still needed. Task-number: QTBUG-51652 Change-Id: Ic87ebb19ddda7d06ea12bd0826ddf10d404a75d8 Reviewed-by: Joerg Bornemann --- tests/auto/widgets/qwebenginepage/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index fcd36ba83..507fb7dbd 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -1,2 +1,5 @@ [macCopyUnicodeToClipboard] osx + +[getUserMediaRequest] +windows -- cgit v1.2.3 From ca6762abde85fe3104ec4f064b85319474ba2deb Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 10 Jun 2016 15:06:03 +0200 Subject: Fix the IPC webChannelTransport not being available on reload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gin JavaScript binging gets destroyed on page reload after all references to it disappear from the previous document. Do like other gin wrapper and reinstall the transport binding on DidCreateDocumentElement, following how it's done by the MojoBindingsController. Task-number: QTBUG-53411 Change-Id: Ibcd9ef9dbedc5762d4f2210fd81f68e5b9127680 Reviewed-by: Michael BrĂ¼ning --- .../qwebenginescript/tst_qwebenginescript.cpp | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index ad10234f4..d5ecd8841 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -37,6 +37,7 @@ private Q_SLOTS: void scriptModifications(); void webChannel_data(); void webChannel(); + void noTransportWithoutWebChannel(); }; void tst_QWebEngineScript::domEditing() @@ -180,13 +181,17 @@ private: void tst_QWebEngineScript::webChannel_data() { QTest::addColumn("worldId"); - QTest::newRow("MainWorld") << static_cast(QWebEngineScript::MainWorld); - QTest::newRow("ApplicationWorld") << static_cast(QWebEngineScript::ApplicationWorld); + QTest::addColumn("reloadFirst"); + QTest::newRow("MainWorld") << static_cast(QWebEngineScript::MainWorld) << false; + QTest::newRow("ApplicationWorld") << static_cast(QWebEngineScript::ApplicationWorld) << false; + QTest::newRow("MainWorldWithReload") << static_cast(QWebEngineScript::MainWorld) << true; + QTest::newRow("ApplicationWorldWithReload") << static_cast(QWebEngineScript::ApplicationWorld) << true; } void tst_QWebEngineScript::webChannel() { QFETCH(int, worldId); + QFETCH(bool, reloadFirst); QWebEnginePage page; TestObject testObject; QScopedPointer channel(new QWebChannel(this)); @@ -205,6 +210,11 @@ void tst_QWebEngineScript::webChannel() page.scripts().insert(script); page.setHtml(QStringLiteral("")); waitForSignal(&page, SIGNAL(loadFinished(bool))); + if (reloadFirst) { + // Check that the transport is also reinstalled on navigation + page.triggerAction(QWebEnginePage::Reload); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + } page.runJavaScript(QLatin1String( "new QWebChannel(qt.webChannelTransport," " function(channel) {" @@ -218,6 +228,17 @@ void tst_QWebEngineScript::webChannel() QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid)); } +void tst_QWebEngineScript::noTransportWithoutWebChannel() +{ + QWebEnginePage page; + page.setHtml(QStringLiteral("")); + + QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid)); + page.triggerAction(QWebEnginePage::Reload); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid)); +} + QTEST_MAIN(tst_QWebEngineScript) #include "tst_qwebenginescript.moc" -- cgit v1.2.3 From 818a2ce5dc773db55938968d5f6e7a2fd758f68a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 Jun 2016 16:19:29 +0200 Subject: Fix translation of multiple pressed mouse buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were reporting any mouse button event where the left mouse button was held as a left mouse button event. We should instead separate the button changed and the ones held. Also adds test of the translation. Change-Id: I1139d6615d54a036dfe843fdb1d1c90b23b467b5 Reviewed-by: Alexandru Croitor Reviewed-by: Michael BrĂ¼ning --- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index f8012c1df..4cff50d3b 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -236,6 +236,7 @@ private Q_SLOTS: void toPlainTextLoadFinishedRace_data(); void toPlainTextLoadFinishedRace(); void setZoomFactor(); + void mouseButtonTranslation(); private: QWebEngineView* m_view; @@ -4990,5 +4991,40 @@ void tst_QWebEnginePage::setZoomFactor() delete page; } +void tst_QWebEnginePage::mouseButtonTranslation() +{ + QWebEngineView *view = new QWebEngineView; + + QSignalSpy spy(view, SIGNAL(loadFinished(bool))); + view->setHtml(QStringLiteral( + "\ + \ +
\ +
\ + ")); + view->show(); + QTest::qWaitForWindowExposed(view); + QTRY_VERIFY(spy.count() == 1); + + QVERIFY(view->focusProxy() != nullptr); + + QMouseEvent evpres(QEvent::MouseButtonPress, view->rect().center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QGuiApplication::sendEvent(view->focusProxy(), &evpres); + + QTRY_COMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.button").toInt(), 0); + QCOMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.buttons").toInt(), 1); + + QMouseEvent evpres2(QEvent::MouseButtonPress, view->rect().center(), Qt::RightButton, Qt::LeftButton | Qt::RightButton, Qt::NoModifier); + QGuiApplication::sendEvent(view->focusProxy(), &evpres2); + + QTRY_COMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.button").toInt(), 2); + QCOMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.buttons").toInt(), 3); + + delete view; +} + QTEST_MAIN(tst_QWebEnginePage) #include "tst_qwebenginepage.moc" -- cgit v1.2.3 From 57f826abff6155c017f76eba1958979a2bc143a4 Mon Sep 17 00:00:00 2001 From: Adam Kallai Date: Thu, 28 Apr 2016 12:04:10 +0200 Subject: Add QML test for scrollPosition Change-Id: Ia7541befb43d2b6fdd09b13ca51fc7d09b955964 Reviewed-by: Peter Varga --- .../auto/quick/qmltests/data/TestWebEngineView.qml | 2 +- tests/auto/quick/qmltests/data/test4.html | 11 +++ .../quick/qmltests/data/tst_scrollPosition.qml | 81 ++++++++++++++++++++++ tests/auto/quick/qmltests/qmltests.pro | 1 + 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 tests/auto/quick/qmltests/data/tst_scrollPosition.qml (limited to 'tests') diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml index 34fc5fb2f..0d2a34645 100644 --- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml +++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml @@ -28,7 +28,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtWebEngine 1.2 +import QtWebEngine 1.3 WebEngineView { property var loadStatus: null diff --git a/tests/auto/quick/qmltests/data/test4.html b/tests/auto/quick/qmltests/data/test4.html index 8f75af606..142b53668 100644 --- a/tests/auto/quick/qmltests/data/test4.html +++ b/tests/auto/quick/qmltests/data/test4.html @@ -12,6 +12,17 @@ +

+ +
bla00
bla01
diff --git a/tests/auto/quick/qmltests/data/tst_scrollPosition.qml b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml new file mode 100644 index 000000000..08bb0f3b4 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtTest 1.0 +import QtWebEngine 1.3 + +TestWebEngineView { + id: webEngineView + width: 300 + height: 400 + + property var testUrl: Qt.resolvedUrl("test4.html") + + SignalSpy { + id: scrollPositionSpy + target: webEngineView + signalName: "onScrollPositionChanged" + } + + TestCase { + name: "ScrollPosition" + when: windowShown + + function init() { + webEngineView.url = Qt.resolvedUrl("about:blank"); + verify(webEngineView.waitForLoadSucceeded()); + } + + function test_scrollPosition() { + webEngineView.url = testUrl; + verify(webEngineView.waitForLoadSucceeded()); + + keyPress(Qt.Key_Return); // Focus is on the scroll button. + + tryCompare(scrollPositionSpy, "count", 1); + compare(webEngineView.scrollPosition.x, 0); + compare(webEngineView.scrollPosition.y, 600); + } + + function test_scrollPositionAfterReload() { + webEngineView.url = testUrl; + verify(webEngineView.waitForLoadSucceeded()); + tryCompare(webEngineView.scrollPosition, "y", 0); + + keyPress(Qt.Key_Return); // Focus is on the scroll button. + scrollPositionSpy.wait(); + + webEngineView.reload(); + verify(webEngineView.waitForLoadSucceeded()); + + tryCompare(webEngineView.scrollPosition, "x", 0); + tryCompare(webEngineView.scrollPosition, "y", 600); + } + } +} diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index 64f7414ce..0158a7268 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -59,6 +59,7 @@ OTHER_FILES += \ $$PWD/data/tst_navigationRequested.qml \ $$PWD/data/tst_properties.qml \ $$PWD/data/tst_runJavaScript.qml \ + $$PWD/data/tst_scrollPosition.qml \ $$PWD/data/tst_titleChanged.qml \ $$PWD/data/tst_unhandledKeyEventPropagation.qml \ $$PWD/data/tst_userScripts.qml \ -- cgit v1.2.3 From 92a28473afb97ee50332f6fe81960c7241ca82d5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 16 Jun 2016 11:34:07 +0200 Subject: Stabilize FilePicker QML autotests Switch from timed wait to using tryCompare. Task-number: QTBUG-53777 Change-Id: I845fb8ee7b84641bd23314794512960634423d54 Reviewed-by: Joerg Bornemann --- tests/auto/quick/qmltests/data/tst_filePicker.qml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml index 02b2dd024..f9c50c4e8 100644 --- a/tests/auto/quick/qmltests/data/tst_filePicker.qml +++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml @@ -81,10 +81,8 @@ TestWebEngineView { FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html")) keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog. - wait(100) // The ui delegate is invoked asynchronously - verify(FilePickerParams.filePickerOpened) - titleSpy.wait() - compare(webEngineView.title, "test1.html") + tryCompare(FilePickerParams, "filePickerOpened", true) + tryCompare(webEngineView, "title", "test1.html") } function test_acceptMultipleFilesSelection() { @@ -96,10 +94,8 @@ TestWebEngineView { FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test2.html")) keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog. - wait(100) - verify(FilePickerParams.filePickerOpened) - titleSpy.wait() - compare(webEngineView.title, "test1.html,test2.html") + tryCompare(FilePickerParams, "filePickerOpened", true) + tryCompare(webEngineView, "title", "test1.html,test2.html") } function test_acceptDirectory() { @@ -110,10 +106,8 @@ TestWebEngineView { FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data")) keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog. - wait(100) // The ui delegate is invoked asynchronously - verify(FilePickerParams.filePickerOpened) - titleSpy.wait() - compare(webEngineView.title, "data") + tryCompare(FilePickerParams, "filePickerOpened", true) + tryCompare(webEngineView, "title", "data") } function test_reject() { -- cgit v1.2.3