summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/inspectorserver/tst_inspectorserver.cpp')
-rw-r--r--tests/auto/quick/inspectorserver/tst_inspectorserver.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
index 6c22c5d33..a9638bee4 100644
--- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
+++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
@@ -9,6 +9,7 @@
#include <QtTest/QtTest>
#include <QQuickWebEngineProfile>
#include <QtWebEngineQuick/private/qquickwebengineview_p.h>
+#include <QWebEnginePage>
#define INSPECTOR_SERVER_PORT "23654"
static const QUrl s_inspectorServerHttpBaseUrl("http://localhost:" INSPECTOR_SERVER_PORT);
@@ -22,6 +23,7 @@ private Q_SLOTS:
void init();
void cleanup();
+ void testDevToolsId();
void testPageList();
void testRemoteDebuggingMessage();
void openRemoteDebuggingSession();
@@ -36,6 +38,7 @@ private:
tst_InspectorServer::tst_InspectorServer()
{
+ qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--remote-allow-origins=*");
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", INSPECTOR_SERVER_PORT);
QtWebEngineQuick::initialize();
QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
@@ -78,7 +81,7 @@ inline QQuickWebEngineView* tst_InspectorServer::webView() const
QJsonArray tst_InspectorServer::fetchPageList() const
{
QNetworkAccessManager qnam;
- QSignalSpy spy(&qnam, &QNetworkAccessManager::finished);;
+ QSignalSpy spy(&qnam, &QNetworkAccessManager::finished);
QNetworkRequest request(s_inspectorServerHttpBaseUrl.resolved(QUrl("json/list")));
QScopedPointer<QNetworkReply> reply(qnam.get(request));
spy.wait();
@@ -90,6 +93,21 @@ QJsonArray tst_InspectorServer::fetchPageList() const
return QJsonDocument::fromJson(reply->readAll()).array();
}
+void tst_InspectorServer::testDevToolsId()
+{
+ const QUrl testPageUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
+ + QLatin1String("/html/basic_page.html"));
+ QSignalSpy loadSpy(webView(), SIGNAL(loadingChanged(QWebEngineLoadingInfo)));
+ webView()->setUrl(testPageUrl);
+ QTRY_VERIFY_WITH_TIMEOUT(loadSpy.size() && !webView()->isLoading(), 10000);
+
+ // Our page should be the only one in the list.
+ QJsonArray pageList = fetchPageList();
+ QCOMPARE(pageList.size(), 1);
+ QCOMPARE(testPageUrl.toString(), pageList.at(0).toObject().value("url").toString());
+ QCOMPARE(webView()->devToolsId(), pageList.at(0).toObject().value("id").toString());
+}
+
void tst_InspectorServer::testPageList()
{
const QUrl testPageUrl = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
@@ -136,7 +154,7 @@ void tst_InspectorServer::testRemoteDebuggingMessage()
.arg(pageList.at(0).toObject().value("webSocketDebuggerUrl").toString())
.arg(jsExpression));
- QTRY_COMPARE(webSocketQueryWebView->title(), jsExpressionResult);
+ QTRY_COMPARE_WITH_TIMEOUT(webSocketQueryWebView->title(), jsExpressionResult, 10000);
}
void tst_InspectorServer::openRemoteDebuggingSession()
@@ -160,7 +178,7 @@ void tst_InspectorServer::openRemoteDebuggingSession()
// - The page list didn't return a valid inspector URL
// - Or the front-end couldn't be loaded through the inspector HTTP server
// - Or the web socket connection couldn't be established between the front-end and the page through the inspector server
- QTRY_VERIFY_WITH_TIMEOUT(inspectorWebView->title().startsWith("DevTools -"), 30000);
+ QTRY_VERIFY_WITH_TIMEOUT(inspectorWebView->title().startsWith("DevTools -"), 60000);
}
QTEST_MAIN(tst_InspectorServer)