diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-03-19 15:59:05 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-03-20 07:28:52 +0100 |
commit | df93624cc31e9da29532eed1d86c9f172575355a (patch) | |
tree | c557d069ae6a4dcffc1da0267af5abe67c0d663d /tests | |
parent | 12420abbfa66e03938571528647be6f6d9034aa7 (diff) |
Set the httpUserAgent after the component has been completed
Since httpUserAgent can be set as a property then it should account for
the fact that init() has not yet been called. So ensure that the
httpUserAgent is set on the profile created when init() is called.
Fixes: QTBUG-82778
Change-Id: I072676e719eedcb0fbc8024f3e902fd1b7073a3e
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qquickwebview/tst_qquickwebview.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp b/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp index e3162bc..b1a1364 100644 --- a/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp +++ b/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp @@ -68,6 +68,7 @@ private Q_SLOTS: void multipleWebViewWindows(); void multipleWebViews(); void titleUpdate(); + void changeUserAgent(); private: inline QQuickWebView *newWebView(); @@ -75,11 +76,12 @@ private: void runJavaScript(const QString &script); QScopedPointer<TestWindow> m_window; QScopedPointer<QQmlComponent> m_component; + QQmlEngine *engine = nullptr; }; tst_QQuickWebView::tst_QQuickWebView() { - static QQmlEngine *engine = new QQmlEngine(this); + engine = new QQmlEngine(this); m_component.reset(new QQmlComponent(engine, this)); m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n" "import QtWebView 1.1\n" @@ -332,5 +334,19 @@ void tst_QQuickWebView::titleUpdate() } +void tst_QQuickWebView::changeUserAgent() +{ + QQmlComponent userAgentWebView(engine, this); + userAgentWebView.setData(QByteArrayLiteral("import QtQuick 2.0\n" + "import QtWebView 1.14\n" + "WebView {\n" + "httpUserAgent: \"dummy\"\n" + "}"), + QUrl()); + QObject *viewInstance = userAgentWebView.create(); + QQuickWebView *webView = qobject_cast<QQuickWebView *>(viewInstance); + QCOMPARE(webView->httpUserAgent(), "dummy"); +} + QTEST_MAIN(tst_QQuickWebView) #include "tst_qquickwebview.moc" |