Bug 1490661 - Part 6. Add geckoview-junit test for enterkeyhint. r=geckoview-reviewers,agi
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 23 Jun 2020 06:38:18 +0000
changeset 536737 2e38bb7fa4712e0cf4f599cfad0cf6a251eecef2
parent 536736 e3090704a024058cf6e6c2016887f8c251ff8964
child 536738 fe7c13be3ba5f011abd8fe9b0ad1a8176b3f7a93
push id37532
push userabutkovits@mozilla.com
push dateTue, 23 Jun 2020 16:15:06 +0000
treeherdermozilla-central@3add3a174755 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, agi
bugs1490661
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1490661 - Part 6. Add geckoview-junit test for enterkeyhint. r=geckoview-reviewers,agi Differential Revision: https://phabricator.services.mozilla.com/D79647
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TextInputDelegateTest.kt
--- 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
@@ -765,16 +765,54 @@ class TextInputDelegateTest : BaseSessio
                 else -> InputType.TYPE_CLASS_TEXT or
                         InputType.TYPE_TEXT_FLAG_CAP_SENTENCES or
                         InputType.TYPE_TEXT_FLAG_AUTO_CORRECT or
                         InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE
             }))
     }
 
     @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)
 
         mainSession.loadTestPath(INPUTS_PATH)
         mainSession.waitForPageStop()
 
         textContent = ""
         mainSession.evaluateJS("document.querySelector('$id').focus()")