diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2017-09-12 15:48:45 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2017-10-04 14:06:03 +0000 |
commit | 64a5f315206fac2316e0b4a5a65a5d1f66b1a219 (patch) | |
tree | bffae9cca3d595f683664d25a49c86e9a84d9dbc /tests | |
parent | 9d9a22fc48f7de6c356a2527ab1170cd50e7dad8 (diff) |
Disable IME on password input
Task-number: QTBUG-62433
Change-Id: Icdc3355ca9d1ec4fb25d512c56c19aca94ae8928
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 6f0c8f164..f46590bdf 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -364,6 +364,9 @@ void tst_QWebEngineView::microFocusCoordinates() void tst_QWebEngineView::focusInputTypes() { + const QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); + bool imeHasHiddenTextCapability = context && context->hasCapability(QPlatformInputContext::HiddenTextCapability); + QWebEngineView webView; webView.show(); QTest::qWaitForWindowExposed(&webView); @@ -372,19 +375,27 @@ void tst_QWebEngineView::focusInputTypes() webView.load(QUrl("qrc:///resources/input_types.html")); QVERIFY(loadFinishedSpy.wait()); + auto inputMethodQuery = [&webView](Qt::InputMethodQuery query) { + QInputMethodQueryEvent event(query); + QApplication::sendEvent(webView.focusProxy(), &event); + return event.value(query); + }; + // 'text' field QPoint textInputCenter = elementCenter(webView.page(), "textInput"); QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, textInputCenter); QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("textInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhPreferLowercase); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); // 'password' field QPoint passwordInputCenter = elementCenter(webView.page(), "passwordInput"); QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, passwordInputCenter); QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("passwordInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText)); - QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(!webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_COMPARE(inputMethodQuery(Qt::ImEnabled).toBool(), imeHasHiddenTextCapability); // 'tel' field QPoint telInputCenter = elementCenter(webView.page(), "telInput"); @@ -392,6 +403,7 @@ void tst_QWebEngineView::focusInputTypes() QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("telInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhDialableCharactersOnly); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); // 'number' field QPoint numberInputCenter = elementCenter(webView.page(), "numberInput"); @@ -399,6 +411,7 @@ void tst_QWebEngineView::focusInputTypes() QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("numberInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhFormattedNumbersOnly); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); // 'email' field QPoint emailInputCenter = elementCenter(webView.page(), "emailInput"); @@ -406,6 +419,7 @@ void tst_QWebEngineView::focusInputTypes() QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("emailInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhEmailCharactersOnly); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); // 'url' field QPoint urlInputCenter = elementCenter(webView.page(), "urlInput"); @@ -413,24 +427,28 @@ void tst_QWebEngineView::focusInputTypes() QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("urlInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhUrlCharactersOnly | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase)); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); // 'password' field QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, passwordInputCenter); QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("passwordInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText)); - QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(!webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_COMPARE(inputMethodQuery(Qt::ImEnabled).toBool(), imeHasHiddenTextCapability); // 'text' type QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, textInputCenter); QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("textInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), Qt::ImhPreferLowercase); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); // 'password' field QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, 0, passwordInputCenter); QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("passwordInput")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText)); - QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(!webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_COMPARE(inputMethodQuery(Qt::ImEnabled).toBool(), imeHasHiddenTextCapability); // 'text area' field QPoint textAreaCenter = elementCenter(webView.page(), "textArea"); @@ -438,6 +456,7 @@ void tst_QWebEngineView::focusInputTypes() QTRY_COMPARE(evaluateJavaScriptSync(webView.page(), "document.activeElement.id").toString(), QStringLiteral("textArea")); VERIFY_INPUTMETHOD_HINTS(webView.focusProxy()->inputMethodHints(), (Qt::ImhMultiLine | Qt::ImhPreferLowercase)); QVERIFY(webView.focusProxy()->testAttribute(Qt::WA_InputMethodEnabled)); + QTRY_VERIFY(inputMethodQuery(Qt::ImEnabled).toBool()); } class KeyEventRecordingWidget : public QWidget { @@ -1885,7 +1904,7 @@ void tst_QWebEngineView::hiddenText() 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()->testAttribute(Qt::WA_InputMethodEnabled)); QVERIFY(view.focusProxy()->inputMethodHints() & Qt::ImhHiddenText); QPoint textInputCenter = elementCenter(view.page(), "input1"); |