summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp30
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp32
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 60e495137..d39a6df54 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -61,6 +61,8 @@ private Q_SLOTS:
void inputMethodHints();
void basicRenderingSanity();
void setZoomFactor();
+ void stopSettingFocusWhenDisabled();
+ void stopSettingFocusWhenDisabled_data();
private:
inline QQuickWebEngineView *newWebEngineView();
@@ -481,5 +483,33 @@ void tst_QQuickWebEngineView::setZoomFactor()
QVERIFY(qFuzzyCompare(view->zoomFactor(), 2.5));
}
+void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled()
+{
+ QFETCH(bool, viewEnabled);
+ QFETCH(bool, activeFocusResult);
+
+ QQuickWebEngineView *view = webEngineView();
+ m_window->show();
+ view->setSize(QSizeF(640, 480));
+ view->setEnabled(viewEnabled);
+ view->loadHtml("<html><head><title>Title</title></head><body>Hello"
+ "<input id=\"input\" type=\"text\"></body></html>");
+ QVERIFY(waitForLoadSucceeded(view));
+
+ // When enabled, the view should get active focus after the page is loaded.
+ QTRY_COMPARE_WITH_TIMEOUT(view->hasActiveFocus(), activeFocusResult, 1000);
+ view->runJavaScript("document.getElementById(\"input\").focus()");
+ QTRY_COMPARE_WITH_TIMEOUT(view->hasActiveFocus(), activeFocusResult, 1000);
+}
+
+void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled_data()
+{
+ QTest::addColumn<bool>("viewEnabled");
+ QTest::addColumn<bool>("activeFocusResult");
+
+ QTest::newRow("enabled view gets active focus") << true << true;
+ QTest::newRow("disabled view does not get active focus") << false << false;
+}
+
QTEST_MAIN(tst_QQuickWebEngineView)
#include "tst_qquickwebengineview.moc"
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index d496362f9..e66bf18cd 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -70,6 +70,8 @@ private Q_SLOTS:
#endif
void doNotSendMouseKeyboardEventsWhenDisabled();
void doNotSendMouseKeyboardEventsWhenDisabled_data();
+ void stopSettingFocusWhenDisabled();
+ void stopSettingFocusWhenDisabled_data();
};
// This will be called before the first test function is executed.
@@ -709,5 +711,35 @@ void tst_QWebEngineView::doNotSendMouseKeyboardEventsWhenDisabled_data()
QTest::newRow("disabled view does not receive events") << false << 4;
}
+void tst_QWebEngineView::stopSettingFocusWhenDisabled()
+{
+ QFETCH(bool, viewEnabled);
+ QFETCH(bool, focusResult);
+
+ QWebEngineView webView;
+ webView.resize(640, 480);
+ webView.show();
+ webView.setEnabled(viewEnabled);
+ QTest::qWaitForWindowExposed(&webView);
+
+ QSignalSpy loadSpy(&webView, SIGNAL(loadFinished(bool)));
+ webView.setHtml("<html><head><title>Title</title></head><body>Hello"
+ "<input id=\"input\" type=\"text\"></body></html>");
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ QTRY_COMPARE_WITH_TIMEOUT(webView.hasFocus(), focusResult, 1000);
+ evaluateJavaScriptSync(webView.page(), "document.getElementById(\"input\").focus()");
+ QTRY_COMPARE_WITH_TIMEOUT(webView.hasFocus(), focusResult, 1000);
+}
+
+void tst_QWebEngineView::stopSettingFocusWhenDisabled_data()
+{
+ QTest::addColumn<bool>("viewEnabled");
+ QTest::addColumn<bool>("focusResult");
+
+ QTest::newRow("enabled view gets focus") << true << true;
+ QTest::newRow("disabled view does not get focus") << false << false;
+}
+
QTEST_MAIN(tst_QWebEngineView)
#include "tst_qwebengineview.moc"