diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2021-07-13 17:56:05 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2021-07-21 14:49:27 +0200 |
commit | 996219643c5f1df01ded257917ccde427f14a939 (patch) | |
tree | 38cbe970f22eea9c799f4b9a78652cd03d4c54df /src | |
parent | ed5bee7adccde92d8aa35e166e45d667f16dea27 (diff) |
Get rid of Quick's TestSupport API
- Moved TestInputContext and TestInputEvent APIs to tst_qmltests.
- Removed loadVisuallyCommitted and use Item.grabToImage to check if
page is rendered.
- Removed windowCloseRejected signal and use a hidden callback instead.
Change-Id: Ica6e4c6017426e0171d738a6a59afa557c786698
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit 9c663f51c63f7661edcc604ce89171b3f037543d)
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
19 files changed, 5 insertions, 478 deletions
diff --git a/src/core/api/qwebenginepage_p.h b/src/core/api/qwebenginepage_p.h index 811bec52e..d661fd442 100644 --- a/src/core/api/qwebenginepage_p.h +++ b/src/core/api/qwebenginepage_p.h @@ -134,7 +134,6 @@ public: QColor backgroundColor() const override; void loadStarted(QWebEngineLoadingInfo info) override; void loadCommitted() override { } - void didFirstVisuallyNonEmptyPaint() override { } void loadFinished(QWebEngineLoadingInfo info) override; void focusContainer() override; void unhandledKeyEvent(QKeyEvent *event) override; diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h index ebf49e8c3..ef7ba7f8d 100644 --- a/src/core/common/qt_messages.h +++ b/src/core/common/qt_messages.h @@ -22,12 +22,6 @@ IPC_MESSAGE_ROUTED2(QtWebEngineMsg_RequestStorageAccessAsyncResponse, bool /* allowed */) //----------------------------------------------------------------------------- -// WebContents messages -// These are messages sent from the renderer back to the browser process. - -IPC_MESSAGE_ROUTED0(RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout) - -//----------------------------------------------------------------------------- // Misc messages // These are messages sent from the renderer to the browser process. diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 7f7d7bcaa..9d5744cbf 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -41,7 +41,6 @@ #include "render_widget_host_view_qt.h" #include "browser_accessibility_manager_qt.h" -#include "common/qt_messages.h" #include "qtwebenginecoreglobal_p.h" #include "render_widget_host_view_qt_delegate.h" #include "render_widget_host_view_qt_delegate_client.h" @@ -820,11 +819,6 @@ void RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete(const cc::Rende synchronizeVisualProperties(metadata.local_surface_id); } -void RenderWidgetHostViewQt::OnDidFirstVisuallyNonEmptyPaint() -{ - m_adapterClient->didFirstVisuallyNonEmptyPaint(); -} - Compositor::Id RenderWidgetHostViewQt::compositorId() { return m_uiCompositor->frame_sink_id(); diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 7f102547f..15ef4fa2a 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -188,9 +188,6 @@ public: void processMotionEvent(const ui::MotionEvent &motionEvent); void resetInputManagerState() { m_imState = 0; } - // Called from WebContentsDelegateQt. - void OnDidFirstVisuallyNonEmptyPaint(); - // Called from WebContentsAdapter. gfx::SizeF lastContentsSize() const { return m_lastContentsSize; } gfx::Vector2dF lastScrollOffset() const { return m_lastScrollOffset; } diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 42a5a3ab0..2e81f21e8 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -195,7 +195,6 @@ public: virtual QColor backgroundColor() const = 0; virtual void loadStarted(QWebEngineLoadingInfo info) = 0; virtual void loadCommitted() = 0; - virtual void didFirstVisuallyNonEmptyPaint() = 0; virtual void loadFinished(QWebEngineLoadingInfo info) = 0; virtual void focusContainer() = 0; virtual void unhandledKeyEvent(QKeyEvent *event) = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 1fcef3274..5366e6a26 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -659,15 +659,6 @@ void WebContentsDelegateQt::OnVisibilityChanged(content::Visibility visibility) web_cache::WebCacheManager::GetInstance()->ObserveActivity(web_contents()->GetMainFrame()->GetProcess()->GetID()); } -void WebContentsDelegateQt::DidFirstVisuallyNonEmptyPaint() -{ - RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt*>(web_contents()->GetRenderWidgetHostView()); - if (!rwhv) - return; - - rwhv->OnDidFirstVisuallyNonEmptyPaint(); -} - void WebContentsDelegateQt::ActivateContents(content::WebContents* contents) { QWebEngineSettings *settings = m_viewClient->webEngineSettings(); diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 9ddd1d192..4704f78fb 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -166,7 +166,6 @@ public: void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) override; void BeforeUnloadFired(bool proceed, const base::TimeTicks& proceed_time) override; void OnVisibilityChanged(content::Visibility visibility) override; - void DidFirstVisuallyNonEmptyPaint() override; void ActivateContents(content::WebContents* contents) override; void ResourceLoadComplete(content::RenderFrameHost* render_frame_host, const content::GlobalRequestID& request_id, diff --git a/src/webenginequick/CMakeLists.txt b/src/webenginequick/CMakeLists.txt index 7c7f9c942..5e56cf53f 100644 --- a/src/webenginequick/CMakeLists.txt +++ b/src/webenginequick/CMakeLists.txt @@ -3,10 +3,6 @@ find_package(Qt6 ${PROJECT_VERSION} CONFIG QUIET OPTIONAL_COMPONENTS PrintSuppor get_configure_mode(configureMode) - -if(QT_FEATURE_webenginequick_testsupport) - add_subdirectory(testsupport) -endif() add_subdirectory(ui) qt_internal_add_qml_module(WebEngineQuick @@ -68,8 +64,3 @@ qt_internal_extend_target(qtwebenginequickplugin make_install_only(WebEngineQuick) make_install_only(qtwebenginequickplugin) - -qt_internal_extend_target(WebEngineQuick CONDITION QT_FEATURE_webenginequick_testsupport - LIBRARIES - Qt::WebEngineTestSupportPrivate -) diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp index e26d5cf25..0f3adca92 100644 --- a/src/webenginequick/api/qquickwebengineview.cpp +++ b/src/webenginequick/api/qquickwebengineview.cpp @@ -99,11 +99,6 @@ #include <QtWebChannel/qqmlwebchannel.h> #endif -#if QT_CONFIG(webenginequick_testsupport) -#include <QtWebEngineTestSupport/private/qquickwebenginetestsupport_p.h> -#endif - - QT_BEGIN_NAMESPACE using namespace QtWebEngineCore; @@ -138,9 +133,6 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() , m_history(new QWebEngineHistory(new QWebEngineHistoryPrivate(this, [] (const QUrl &url) { return QQuickWebEngineFaviconProvider::faviconProviderUrl(url); }))) -#if QT_CONFIG(webenginequick_testsupport) - , m_testSupport(nullptr) -#endif , contextMenuExtraItems(nullptr) , loadProgress(0) , m_fullscreenMode(false) @@ -453,32 +445,6 @@ void QQuickWebEngineViewPrivate::loadCommitted() m_history->reset(); } -void QQuickWebEngineViewPrivate::didFirstVisuallyNonEmptyPaint() -{ -#if QT_CONFIG(webenginequick_testsupport) - if (m_loadVisuallyCommittedState == NotCommitted) { - m_loadVisuallyCommittedState = DidFirstVisuallyNonEmptyPaint; - } else if (m_loadVisuallyCommittedState == DidFirstCompositorFrameSwap) { - if (m_testSupport) - Q_EMIT m_testSupport->loadVisuallyCommitted(); - m_loadVisuallyCommittedState = NotCommitted; - } -#endif -} - -void QQuickWebEngineViewPrivate::didCompositorFrameSwap() -{ -#if QT_CONFIG(webenginequick_testsupport) - if (m_loadVisuallyCommittedState == NotCommitted) { - m_loadVisuallyCommittedState = DidFirstCompositorFrameSwap; - } else if (m_loadVisuallyCommittedState == DidFirstVisuallyNonEmptyPaint) { - if (m_testSupport) - Q_EMIT m_testSupport->loadVisuallyCommitted(); - m_loadVisuallyCommittedState = NotCommitted; - } -#endif -} - void QQuickWebEngineViewPrivate::loadFinished(QWebEngineLoadingInfo info) { Q_Q(QQuickWebEngineView); @@ -552,10 +518,10 @@ void QQuickWebEngineViewPrivate::close() void QQuickWebEngineViewPrivate::windowCloseRejected() { -#if QT_CONFIG(webenginequick_testsupport) - if (m_testSupport) - Q_EMIT m_testSupport->windowCloseRejected(); -#endif + Q_Q(QQuickWebEngineView); + + if (Q_UNLIKELY(q->metaObject()->indexOfMethod("windowCloseRejected()") != -1)) + QMetaObject::invokeMethod(q, "windowCloseRejected"); } void QQuickWebEngineViewPrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen) @@ -1168,21 +1134,6 @@ void QQuickWebEngineViewPrivate::updateAdapter() } } -#if QT_CONFIG(webenginequick_testsupport) -QQuickWebEngineTestSupport *QQuickWebEngineView::testSupport() const -{ - Q_D(const QQuickWebEngineView); - return d->m_testSupport; -} - -void QQuickWebEngineView::setTestSupport(QQuickWebEngineTestSupport *testSupport) -{ - Q_D(QQuickWebEngineView); - d->m_testSupport = testSupport; - Q_EMIT testSupportChanged(); -} -#endif - bool QQuickWebEngineView::activeFocusOnPress() const { Q_D(const QQuickWebEngineView); diff --git a/src/webenginequick/api/qquickwebengineview_p.h b/src/webenginequick/api/qquickwebengineview_p.h index 2e3252777..ab891f4e2 100644 --- a/src/webenginequick/api/qquickwebengineview_p.h +++ b/src/webenginequick/api/qquickwebengineview_p.h @@ -74,7 +74,6 @@ class QQuickWebEngineJavaScriptDialogRequest; class QQuickWebEngineNewViewRequest; class QQuickWebEngineProfile; class QQuickWebEngineSettings; -class QQuickWebEngineTestSupport; class QQuickWebEngineTooltipRequest; class QQuickWebEngineViewPrivate; class QWebEngineCertificateError; @@ -118,9 +117,6 @@ class Q_WEBENGINEQUICK_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QQuickWebEngineView *inspectedView READ inspectedView WRITE setInspectedView NOTIFY inspectedViewChanged REVISION(1,7) FINAL) Q_PROPERTY(QQuickWebEngineView *devToolsView READ devToolsView WRITE setDevToolsView NOTIFY devToolsViewChanged REVISION(1,7) FINAL) -#if QT_CONFIG(webenginequick_testsupport) - Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL) -#endif Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION(1,10) FINAL) Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION(1,10) FINAL) @@ -456,11 +452,6 @@ public: qint64 renderProcessPid() const; -#if QT_CONFIG(webenginequick_testsupport) - QQuickWebEngineTestSupport *testSupport() const; - void setTestSupport(QQuickWebEngineTestSupport *testSupport); -#endif - bool activeFocusOnPress() const; void setInspectedView(QQuickWebEngineView *); @@ -542,10 +533,6 @@ Q_SIGNALS: Q_REVISION(1,11) void canGoBackChanged(); Q_REVISION(1,11) void canGoForwardChanged(); -#if QT_CONFIG(webenginequick_testsupport) - void testSupportChanged(); -#endif - protected: void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; void itemChange(ItemChange, const ItemChangeData &) override; diff --git a/src/webenginequick/api/qquickwebengineview_p_p.h b/src/webenginequick/api/qquickwebengineview_p_p.h index 4f07ce909..da0d79d60 100644 --- a/src/webenginequick/api/qquickwebengineview_p_p.h +++ b/src/webenginequick/api/qquickwebengineview_p_p.h @@ -80,10 +80,6 @@ class QWebEngineContextMenuRequest; class QWebEngineFindTextResult; class QWebEngineHistory; -#if QT_CONFIG(webenginequick_testsupport) -class QQuickWebEngineTestSupport; -#endif - class Q_WEBENGINEQUICK_PRIVATE_EXPORT QQuickWebEngineViewPrivate : public QtWebEngineCore::WebContentsAdapterClient { public: @@ -113,7 +109,6 @@ public: QColor backgroundColor() const override; void loadStarted(QWebEngineLoadingInfo info) override; void loadCommitted() override; - void didFirstVisuallyNonEmptyPaint() override; void loadFinished(QWebEngineLoadingInfo info) override; void focusContainer() override; void unhandledKeyEvent(QKeyEvent *event) override; @@ -168,9 +163,6 @@ public: QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void printRequested() override; void findTextFinished(const QWebEngineFindTextResult &result) override; - - void didCompositorFrameSwap(); - void updateAction(QQuickWebEngineView::WebAction) const; void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents); void setProfile(QQuickWebEngineProfile *profile); @@ -186,9 +178,6 @@ public: QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter; QScopedPointer<QWebEngineHistory> m_history; QScopedPointer<QQuickWebEngineSettings> m_settings; -#if QT_CONFIG(webenginequick_testsupport) - QQuickWebEngineTestSupport *m_testSupport; -#endif QQmlComponent *contextMenuExtraItems; QUrl m_url; QString m_html; @@ -212,18 +201,11 @@ public: bool profileInitialized() const; private: - enum LoadVisuallyCommittedState { - NotCommitted, - DidFirstVisuallyNonEmptyPaint, - DidFirstCompositorFrameSwap - }; - QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager; QColor m_backgroundColor; qreal m_zoomFactor; bool m_profileInitialized; QWebEngineContextMenuRequest *m_contextMenuRequest; - LoadVisuallyCommittedState m_loadVisuallyCommittedState = NotCommitted; QScopedPointer<QQuickWebEngineScriptCollection> m_scriptCollection; QQuickWebEngineFaviconProvider *m_faviconProvider = nullptr; }; diff --git a/src/webenginequick/configure.cmake b/src/webenginequick/configure.cmake index 19dded637..683a3f383 100644 --- a/src/webenginequick/configure.cmake +++ b/src/webenginequick/configure.cmake @@ -6,12 +6,7 @@ qt_feature("webenginequick-ui-delegates" PRIVATE SECTION "WebEngine" LABEL "UI Delegates" ) -qt_feature("webenginequick-testsupport" PRIVATE - LABEL "Test Support" - AUTODETECT QT_FEATURE_webengine_developer_build -) qt_configure_add_summary_section(NAME "Qt WebEngineQuick") qt_configure_add_summary_entry(ARGS "webenginequick-qml") qt_configure_add_summary_entry(ARGS "webenginequick-ui-delegates") -qt_configure_add_summary_entry(ARGS "webenginequick-testsupport") qt_configure_end_summary_section() diff --git a/src/webenginequick/configure.json b/src/webenginequick/configure.json index 6297195e9..ce9421575 100644 --- a/src/webenginequick/configure.json +++ b/src/webenginequick/configure.json @@ -19,11 +19,6 @@ "label": "UI Delegates", "section": "WebEngine", "output": [ "privateFeature" ] - }, - "webenginequick-testsupport": { - "label": "Test Support", - "autoDetect": "features.private_tests || call.isTestsInBuildParts", - "output": [ "privateFeature" ] } }, "summary": [ @@ -31,8 +26,7 @@ "section": "Qt WebEngineQuick", "entries": [ "webengine-quick", - "webenginequick-ui-delegates", - "webenginequick-testsupport" + "webenginequick-ui-delegates" ] } ] diff --git a/src/webenginequick/module.pro b/src/webenginequick/module.pro index 7b494bb5b..2c10aaa73 100644 --- a/src/webenginequick/module.pro +++ b/src/webenginequick/module.pro @@ -56,12 +56,6 @@ HEADERS = \ render_widget_host_view_qt_delegate_quickwindow.h \ ui_delegates_manager.h -qtConfig(webenginequick-testsupport) { - QT_PRIVATE += testlib - SOURCES += api/qquickwebenginetestsupport.cpp - HEADERS += api/qquickwebenginetestsupport_p.h -} - !build_pass { python = $$pythonPathForShell() chromium_attributions.commands = \ diff --git a/src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp b/src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp index c0a48ccd5..c4d80cb7e 100644 --- a/src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp @@ -349,13 +349,6 @@ QSGNode *RenderWidgetHostViewQtDelegateQuick::updatePaintNode(QSGNode *oldNode, Q_UNREACHABLE(); } -#if QT_CONFIG(webenginequick_testsupport) - if (m_view) - QMetaObject::invokeMethod( - m_view, [view = m_view]() { view->d_ptr->didCompositorFrameSwap(); }, - Qt::QueuedConnection); -#endif - return node; } diff --git a/src/webenginequick/testsupport/CMakeLists.txt b/src/webenginequick/testsupport/CMakeLists.txt deleted file mode 100644 index 7058a6029..000000000 --- a/src/webenginequick/testsupport/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -qt_internal_add_qml_module(WebEngineTestSupport - ${configureMode} - URI "QtWebEngine.testsupport" - VERSION "${PROJECT_VERSION}" - CLASS_NAME QtWebEngineTestSupportPlugin - PLUGIN_TARGET qtwebenginetestsupportplugin - NO_PLUGIN_OPTIONAL - SOURCES - qquickwebenginetestsupport.cpp qquickwebenginetestsupport_p.h - DEFINES - QT_BUILD_WEBENGINEQUICK_TESTSUPPORT_LIB - LIBRARIES - Qt::GuiPrivate - Qt::Qml - Qt::TestPrivate - Qt::WebEngineCore -) -make_install_only(WebEngineTestSupport) -make_install_only(qtwebenginetestsupportplugin) diff --git a/src/webenginequick/testsupport/qquickwebenginetestsupport.cpp b/src/webenginequick/testsupport/qquickwebenginetestsupport.cpp deleted file mode 100644 index 15290e0e9..000000000 --- a/src/webenginequick/testsupport/qquickwebenginetestsupport.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** 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:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickwebenginetestsupport_p.h" - -#include <QtWebEngineCore/qwebengineloadinginfo.h> - -#include <QQuickItem> -#include <QQuickWindow> -#include <QtTest/qtest.h> -#include <QtCore/QTimer> - -QT_BEGIN_NAMESPACE - -namespace QTest { - int Q_TESTLIB_EXPORT defaultMouseDelay(); -} - -QQuickWebEngineTestInputContext::QQuickWebEngineTestInputContext() - : m_visible(false) -{ -} - -QQuickWebEngineTestInputContext::~QQuickWebEngineTestInputContext() -{ - release(); -} - -void QQuickWebEngineTestInputContext::create() -{ - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = this; -} - -void QQuickWebEngineTestInputContext::release() -{ - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; -} - -void QQuickWebEngineTestInputContext::showInputPanel() -{ - m_visible = true; -} - -void QQuickWebEngineTestInputContext::hideInputPanel() -{ - m_visible = false; -} - -bool QQuickWebEngineTestInputContext::isInputPanelVisible() const -{ - return m_visible; -} - - -QQuickWebEngineTestEvent::QQuickWebEngineTestEvent() -{ -} - -bool QQuickWebEngineTestEvent::mouseMultiClick(QObject *item, qreal x, qreal y, int clickCount) -{ - QTEST_ASSERT(item); - - QWindow *view = eventWindow(item); - if (!view) - return false; - - for (int i = 0; i < clickCount; ++i) { - mouseEvent(QMouseEvent::MouseButtonPress, view, item, QPointF(x, y)); - mouseEvent(QMouseEvent::MouseButtonRelease, view, item, QPointF(x, y)); - } - QTest::lastMouseTimestamp += QTest::mouseDoubleClickInterval; - - return true; -} - -QWindow *QQuickWebEngineTestEvent::eventWindow(QObject *item) -{ - QWindow *window = qobject_cast<QWindow *>(item); - if (window) - return window; - - QQuickItem *quickItem = qobject_cast<QQuickItem *>(item); - if (quickItem) - return quickItem->window(); - - QQuickItem *testParentItem = qobject_cast<QQuickItem *>(parent()); - if (testParentItem) - return testParentItem->window(); - - return nullptr; -} - -void QQuickWebEngineTestEvent::mouseEvent(QEvent::Type type, QWindow *window, QObject *item, const QPointF &_pos) -{ - QTest::qWait(QTest::defaultMouseDelay()); - QTest::lastMouseTimestamp += QTest::defaultMouseDelay(); - - QPoint pos; - QQuickItem *sgitem = qobject_cast<QQuickItem *>(item); - if (sgitem) - pos = sgitem->mapToScene(_pos).toPoint(); - - QMouseEvent me(type, pos, window->mapFromGlobal(pos), Qt::LeftButton, Qt::LeftButton, {}); - me.setTimestamp(++QTest::lastMouseTimestamp); - - QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(window, &me)) - QTest::qWarn("Mouse click event not accepted by receiving window"); -} - - -QQuickWebEngineTestSupport::QQuickWebEngineTestSupport() - : m_testInputContext(new QQuickWebEngineTestInputContext) - , m_testEvent(new QQuickWebEngineTestEvent) -{ -} - -QQuickWebEngineTestInputContext *QQuickWebEngineTestSupport::testInputContext() const -{ - return m_testInputContext.data(); -} - -QQuickWebEngineTestEvent * QQuickWebEngineTestSupport::testEvent() const -{ - return m_testEvent.data(); -} - -QT_END_NAMESPACE - -#include "moc_qquickwebenginetestsupport_p.cpp" diff --git a/src/webenginequick/testsupport/qquickwebenginetestsupport_p.h b/src/webenginequick/testsupport/qquickwebenginetestsupport_p.h deleted file mode 100644 index c84bf6126..000000000 --- a/src/webenginequick/testsupport/qquickwebenginetestsupport_p.h +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKWEBENGINETESTSUPPORT_P_H -#define QQUICKWEBENGINETESTSUPPORT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QT_STATIC -# if defined(QT_BUILD_WEBENGINEQUICK_TESTSUPPORT_LIB) -# define Q_WEBENGINEQUICK_TESTSUPPORT_EXPORT Q_DECL_EXPORT -# else -# define Q_WEBENGINEQUICK_TESTSUPPORT_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_WEBENGINEQUICK_TESTSUPPORT_EXPORT -#endif - -#include <QtGui/private/qinputmethod_p.h> -#include <QtQml/qqmlregistration.h> - -#include <QEvent> -#include <QObject> -#include <QUrl> - -QT_BEGIN_NAMESPACE - -class QWebEngineLoadingInfo; -class QWindow; - -class Q_WEBENGINEQUICK_TESTSUPPORT_EXPORT QQuickWebEngineTestInputContext : public QPlatformInputContext { - Q_OBJECT - QML_NAMED_ELEMENT(TestInputContext) - QML_ADDED_IN_VERSION(1, 0) - QML_EXTRA_VERSION(2, 0) - QML_UNCREATABLE("") - -public: - QQuickWebEngineTestInputContext(); - ~QQuickWebEngineTestInputContext(); - - Q_INVOKABLE void create(); - Q_INVOKABLE void release(); - - void showInputPanel() override; - void hideInputPanel() override; - bool isInputPanelVisible() const override; - -private: - bool m_visible; -}; - -class Q_WEBENGINEQUICK_TESTSUPPORT_EXPORT QQuickWebEngineTestEvent : public QObject { - Q_OBJECT - QML_NAMED_ELEMENT(WebEngineTestEvent) - QML_ADDED_IN_VERSION(1, 0) - QML_EXTRA_VERSION(2, 0) - QML_UNCREATABLE("") - -public: - QQuickWebEngineTestEvent(); - -public Q_SLOTS: - bool mouseMultiClick(QObject *item, qreal x, qreal y, int clickCount); - -private: - QWindow *eventWindow(QObject *item = nullptr); - void mouseEvent(QEvent::Type type, QWindow *window, QObject *item, const QPointF &_pos); -}; - -class Q_WEBENGINEQUICK_TESTSUPPORT_EXPORT QQuickWebEngineTestSupport : public QObject { - Q_OBJECT - Q_PROPERTY(QQuickWebEngineTestInputContext *testInputContext READ testInputContext CONSTANT FINAL) - Q_PROPERTY(QQuickWebEngineTestEvent *testEvent READ testEvent CONSTANT FINAL) - QML_NAMED_ELEMENT(WebEngineTestSupport) - QML_ADDED_IN_VERSION(1, 0) - QML_EXTRA_VERSION(2, 0) - -public: - QQuickWebEngineTestSupport(); - QQuickWebEngineTestInputContext *testInputContext() const; - QQuickWebEngineTestEvent *testEvent() const; - -Q_SIGNALS: - void windowCloseRejected(); - void loadVisuallyCommitted(); - -private: - QScopedPointer<QQuickWebEngineTestInputContext> m_testInputContext; - QScopedPointer<QQuickWebEngineTestEvent> m_testEvent; -}; - -QT_END_NAMESPACE - -#endif // QQUICKWEBENGINETESTSUPPORT_P_H diff --git a/src/webenginequick/webenginequick.pro b/src/webenginequick/webenginequick.pro index 17b3bd0fa..d7271a220 100644 --- a/src/webenginequick/webenginequick.pro +++ b/src/webenginequick/webenginequick.pro @@ -7,12 +7,6 @@ qml_plugin.depends = qml_module SUBDIRS += qml_module qml_plugin -qtConfig(webenginequick-testsupport) { - testsupport_plugin.file = testsupport/testsupport.pro - testsupport_plugin.depends = qml_module - SUBDIRS += testsupport_plugin -} - qtConfig(webenginequick-ui-delegates) { SUBDIRS += ui } |