diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-03-02 17:30:07 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-03-02 17:30:27 +0100 |
commit | d058d6c9df1ff866e4259ca2989ad144bb01a1e0 (patch) | |
tree | d91f8c314c20781080819d100df6a9855b30fbfd /tests/auto/widgets/qwebengineview | |
parent | 0c6312dfba960365771c64b937579a40e02ea5f7 (diff) | |
parent | 3f1805f8569337a21b72324d5edad329d5dfe872 (diff) |
Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: Iff6ab3c287c58d8ec84a1513460bfce5218e8a61
Diffstat (limited to 'tests/auto/widgets/qwebengineview')
-rw-r--r-- | tests/auto/widgets/qwebengineview/BLACKLIST | 3 | ||||
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 50 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST index 0a909d0f6..d249ac141 100644 --- a/tests/auto/widgets/qwebengineview/BLACKLIST +++ b/tests/auto/widgets/qwebengineview/BLACKLIST @@ -1,2 +1,5 @@ [doNotSendMouseKeyboardEventsWhenDisabled] windows +[changeLocale] +windows +linux diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 3b683e541..3e8f1fb1e 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -87,6 +87,7 @@ private Q_SLOTS: void stopSettingFocusWhenDisabled_data(); void focusOnNavigation_data(); void focusOnNavigation(); + void focusInternalRenderWidgetHostViewQuickItem(); void changeLocale(); void inputMethodsTextFormat_data(); @@ -858,11 +859,60 @@ void tst_QWebEngineView::focusOnNavigation() webView->setFocus(); QTRY_COMPARE(webView->hasFocus(), true); + // Clean up. #undef loadAndTriggerFocusAndCompare #undef triggerJavascriptFocus } +void tst_QWebEngineView::focusInternalRenderWidgetHostViewQuickItem() +{ + // Create a container widget, that will hold a line edit that has initial focus, and a web + // engine view. + QScopedPointer<QWidget> containerWidget(new QWidget); + QLineEdit *label = new QLineEdit; + label->setText(QString::fromLatin1("Text")); + label->setFocus(); + + // Create the web view, and set its focusOnNavigation property to false, so it doesn't + // get initial focus. + QWebEngineView *webView = new QWebEngineView; + QWebEngineSettings *settings = webView->page()->settings(); + settings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); + webView->resize(300, 300); + + QHBoxLayout *layout = new QHBoxLayout; + layout->addWidget(label); + layout->addWidget(webView); + + containerWidget->setLayout(layout); + containerWidget->show(); + QTest::qWaitForWindowExposed(containerWidget.data()); + + // Load the content, and check that focus is not set. + 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(webView->hasFocus(), false); + + // Manually trigger focus. + webView->setFocus(); + + // Check that focus is set in QWebEngineView and all internal classes. + QTRY_COMPARE(webView->hasFocus(), true); + + QQuickWidget *renderWidgetHostViewQtDelegateWidget = + qobject_cast<QQuickWidget *>(webView->focusProxy()); + QVERIFY(renderWidgetHostViewQtDelegateWidget); + QTRY_COMPARE(renderWidgetHostViewQtDelegateWidget->hasFocus(), true); + + QQuickItem *renderWidgetHostViewQuickItem = + renderWidgetHostViewQtDelegateWidget->rootObject(); + QVERIFY(renderWidgetHostViewQuickItem); + QTRY_COMPARE(renderWidgetHostViewQuickItem->hasFocus(), true); +} + void tst_QWebEngineView::changeLocale() { QSKIP("Error pages no longer have useful titles in Chromium 55"); |