diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-12-19 16:51:45 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2017-01-20 13:01:11 +0000 |
commit | 9cc6592de3029da98be34a54b56bbd004e93d569 (patch) | |
tree | 425d7448223fcb8825962be7c6fa6cb05ccd375e /tests/auto | |
parent | 4634c2467875e44a5cae5bc1ce015ca7a8115682 (diff) |
Make input method hints available via RWHV delegate widget
Moreover, set ImHiddenText hint for password fields and add back the
corresponding widget auto test.
Task-number: QTBUG-55766
Change-Id: I3f76e19c8c33e11f3d9f515b6dc7d6e998c3c9a4
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 28 | ||||
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 26 |
2 files changed, 26 insertions, 28 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 059b20d4c..00570a169 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -1637,24 +1637,6 @@ void tst_QWebEnginePage::inputMethods_data() } #if defined(QWEBENGINEPAGE_INPUTMETHODQUERY) -static Qt::InputMethodHints inputMethodHints(QObject* object) -{ - if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object)) - return o->inputMethodHints(); - if (QWidget* w = qobject_cast<QWidget*>(object)) - return w->inputMethodHints(); - return Qt::InputMethodHints(); -} - -static bool inputMethodEnabled(QObject* object) -{ - if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object)) - return o->flags() & QGraphicsItem::ItemAcceptsInputMethod; - if (QWidget* w = qobject_cast<QWidget*>(object)) - return w->testAttribute(Qt::WA_InputMethodEnabled); - return false; -} - static void clickOnPage(QWebEnginePage* page, const QPoint& position) { QMouseEvent evpres(QEvent::MouseButtonPress, position, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); @@ -1900,16 +1882,6 @@ void tst_QWebEnginePage::inputMethods() //END - Tests for Selection when the Editor is not in Composition mode - //ImhHiddenText - QPoint passwordInputCenter = inputs.at(1).geometry().center(); - clickOnPage(page, passwordInputCenter); - - QVERIFY(inputMethodEnabled(view)); - QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText); - - clickOnPage(page, textInputCenter); - QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText)); - //START - Test for sending empty QInputMethodEvent page->setHtml("<html><body>" \ "<input type='text' id='input3' value='QtWebEngine2'/>" \ diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 2acf2f939..5b99f0787 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -92,6 +92,7 @@ private Q_SLOTS: void keyboardFocusAfterPopup(); void softwareInputPanel(); + void hiddenText(); }; // This will be called before the first test function is executed. @@ -1193,5 +1194,30 @@ void tst_QWebEngineView::softwareInputPanel() QVERIFY(!testContext.isInputPanelVisible()); } +void tst_QWebEngineView::hiddenText() +{ + QWebEngineView view; + view.show(); + + QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool))); + view.setHtml("<html><body>" + " <input type='text' id='input1' value='QtWebEngine' size='50'/><br>" + " <input type='password' id='password1'/>" + "</body></html>"); + QVERIFY(loadFinishedSpy.wait()); + + QPoint passwordInputCenter = elementCenter(view.page(), "password1"); + QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, passwordInputCenter); + QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("password1")); + + QVERIFY(view.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(view.focusProxy()->inputMethodHints() & Qt::ImhHiddenText); + + QPoint textInputCenter = elementCenter(view.page(), "input1"); + QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter); + QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1")); + QVERIFY(!(view.focusProxy()->inputMethodHints() & Qt::ImhHiddenText)); +} + QTEST_MAIN(tst_QWebEngineView) #include "tst_qwebengineview.moc" |