summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-01-16 22:43:07 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-02-01 10:53:04 +0100
commita6fb2c592bac997baf87016e9dd6b7a3c061ef3c (patch)
treeee41adcddb4868053830840826fa62abb6411330 /tests
parent3d22e15a3f1a54427b870e4df97e3898fe8c8339 (diff)
Add getter/signal to get the render process PID
This can useful for e.g. implementing something like the "Task manager" in Chromium or otherwise interacting with the render process (e.g. to kill it for some reason while debugging). [ChangeLog] Add a renderProcessPid() getter to (Q)WebEnginePage which allows getting the process ID of the underlying render process. Change-Id: Id5d59be9b6bd46ffc3a6aa480cb5ff7bd3b8aa31 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp2
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp19
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 3c97f2410..aaca7997b 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -741,6 +741,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.quotaRequested(QWebEngineQuotaRequest) --> void"
<< "QQuickWebEngineView.recentlyAudible --> bool"
<< "QQuickWebEngineView.recentlyAudibleChanged(bool) --> void"
+ << "QQuickWebEngineView.renderProcessPid --> qlonglong"
+ << "QQuickWebEngineView.renderProcessPidChanged(qlonglong) --> void"
<< "QQuickWebEngineView.recommendedState --> LifecycleState"
<< "QQuickWebEngineView.recommendedStateChanged(LifecycleState) --> void"
<< "QQuickWebEngineView.registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest) --> void"
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index f411f0872..9f4e422f8 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -226,6 +226,7 @@ private Q_SLOTS:
void customUserAgentInNewTab();
void renderProcessCrashed();
+ void renderProcessPid();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4358,6 +4359,24 @@ void tst_QWebEnginePage::renderProcessCrashed()
status == QWebEnginePage::AbnormalTerminationStatus);
}
+void tst_QWebEnginePage::renderProcessPid()
+{
+ QCOMPARE(m_page->renderProcessPid(), 0);
+
+ m_page->load(QUrl("about:blank"));
+ QSignalSpy spyFinished(m_page, &QWebEnginePage::loadFinished);
+ QVERIFY(spyFinished.wait());
+
+ QVERIFY(m_page->renderProcessPid() > 1);
+
+ bool crashed = false;
+ connect(m_page, &QWebEnginePage::renderProcessTerminated, [&]() { crashed = true; });
+ m_page->load(QUrl("chrome://crash"));
+ QTRY_VERIFY_WITH_TIMEOUT(crashed, 20000);
+
+ QCOMPARE(m_page->renderProcessPid(), 0);
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)