From 8dbe6d9df4dd952e6d5f77b1876949099657ce9a Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Tue, 23 Jun 2020 06:38:18 +0000 Subject: [PATCH] Bug 1490661 - Part 6. Add geckoview-junit test for enterkeyhint. r=geckoview-reviewers,agi Differential Revision: https://phabricator.services.mozilla.com/D79647 --- .../geckoview/test/TextInputDelegateTest.kt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TextInputDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TextInputDelegateTest.kt index 46a458847e15..bb9fd5a7e8f6 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TextInputDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TextInputDelegateTest.kt @@ -769,6 +769,44 @@ class TextInputDelegateTest : BaseSessionTest() { })) } + @WithDisplay(width = 512, height = 512) // Child process updates require having a display. + @Test fun editorInfo_enterKeyHint() { + // no way to set enterkeyhint on designmode. + assumeThat("Not in designmode", id, not(equalTo("#designmode"))) + + sessionRule.setPrefsUntilTestEnd(mapOf("dom.forms.enterkeyhint" to true)) + + mainSession.textInput.view = View(InstrumentationRegistry.getInstrumentation().targetContext) + + mainSession.loadTestPath(INPUTS_PATH) + mainSession.waitForPageStop() + + textContent = "" + val values = listOf("enter", "done", "go", "previous", "next", "search", "send") + for (enterkeyhint in values) { + mainSession.evaluateJS(""" + document.querySelector('$id').enterKeyHint = '$enterkeyhint'; + document.querySelector('$id').focus()""") + mainSession.waitUntilCalled(GeckoSession.TextInputDelegate::class, "restartInput") + + val editorInfo = EditorInfo() + mainSession.textInput.onCreateInputConnection(editorInfo) + assertThat("EditorInfo.imeOptions by $enterkeyhint", editorInfo.imeOptions and EditorInfo.IME_MASK_ACTION, equalTo( + when (enterkeyhint) { + "done" -> EditorInfo.IME_ACTION_DONE + "go" -> EditorInfo.IME_ACTION_GO + "next" -> EditorInfo.IME_ACTION_NEXT + "previous" -> EditorInfo.IME_ACTION_PREVIOUS + "search" -> EditorInfo.IME_ACTION_SEARCH + "send" -> EditorInfo.IME_ACTION_SEND + else -> EditorInfo.IME_ACTION_NONE + })) + + mainSession.evaluateJS("document.querySelector('$id').blur()") + mainSession.waitUntilCalled(GeckoSession.TextInputDelegate::class, "restartInput") + } + } + @WithDisplay(width = 512, height = 512) // Child process updates require having a display. @Test fun bug1613804_finishComposingText() { mainSession.textInput.view = View(InstrumentationRegistry.getInstrumentation().targetContext)