summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-04-12 09:22:04 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2018-04-17 11:40:56 +0000
commit313519b844e6a8ad3f54d3ab1554b99eaf0dbf4e (patch)
tree8e6588c5ebef3c1a72e3dbdcd54cc9ec9e25a157
parenta40850f0c165045fd037ff945b00b643031700a9 (diff)
downloadqtwebengine-313519b844e6a8ad3f54d3ab1554b99eaf0dbf4e.tar.gz
Add tst_QWebEnginePage::devTools
Open devtools from autotest. Change-Id: I5e78d6259fdd29df5608b45292ee0a786d179e26 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index d193a07ce..6fd2a06ee 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -216,6 +216,7 @@ private Q_SLOTS:
void registerProtocolHandler_data();
void registerProtocolHandler();
void dataURLFragment();
+ void devTools();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4311,6 +4312,48 @@ void tst_QWebEnginePage::dataURLFragment()
QCOMPARE(m_page->url().fragment(), QStringLiteral("anchor"));
}
+void tst_QWebEnginePage::devTools()
+{
+ QWebEngineProfile profile;
+ QWebEnginePage inspectedPage1(&profile);
+ QWebEnginePage inspectedPage2(&profile);
+ QWebEnginePage devToolsPage(&profile);
+ QSignalSpy spy(&devToolsPage, &QWebEnginePage::loadFinished);
+
+ inspectedPage1.setDevToolsPage(&devToolsPage);
+
+ QCOMPARE(inspectedPage1.devToolsPage(), &devToolsPage);
+ QCOMPARE(inspectedPage1.inspectedPage(), nullptr);
+ QCOMPARE(inspectedPage2.devToolsPage(), nullptr);
+ QCOMPARE(inspectedPage2.inspectedPage(), nullptr);
+ QCOMPARE(devToolsPage.devToolsPage(), nullptr);
+ QCOMPARE(devToolsPage.inspectedPage(), &inspectedPage1);
+
+ QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(spy.takeFirst().value(0).toBool());
+
+ devToolsPage.setInspectedPage(&inspectedPage2);
+
+ QCOMPARE(inspectedPage1.devToolsPage(), nullptr);
+ QCOMPARE(inspectedPage1.inspectedPage(), nullptr);
+ QCOMPARE(inspectedPage2.devToolsPage(), &devToolsPage);
+ QCOMPARE(inspectedPage2.inspectedPage(), nullptr);
+ QCOMPARE(devToolsPage.devToolsPage(), nullptr);
+ QCOMPARE(devToolsPage.inspectedPage(), &inspectedPage2);
+
+ QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(spy.takeFirst().value(0).toBool());
+
+ devToolsPage.setInspectedPage(nullptr);
+
+ QCOMPARE(inspectedPage1.devToolsPage(), nullptr);
+ QCOMPARE(inspectedPage1.inspectedPage(), nullptr);
+ QCOMPARE(inspectedPage2.devToolsPage(), nullptr);
+ QCOMPARE(inspectedPage2.inspectedPage(), nullptr);
+ QCOMPARE(devToolsPage.devToolsPage(), nullptr);
+ QCOMPARE(devToolsPage.inspectedPage(), nullptr);
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)