Skip to content

Commit

Permalink
Bug 1630119 - Set initial text and selection correctly on sendDummyKe…
Browse files Browse the repository at this point in the history
…yboardEvent. r=geckoview-reviewers,owlish

This test is rarely failure when initial text and selection correctly. Because
we don't wait for setting initial data, or it is text is too short to update
text.

So I re-write this tests. And also, this has typo fix for test name.

Differential Revision: https://phabricator.services.mozilla.com/D131048
  • Loading branch information
makotokato committed Nov 15, 2021
1 parent 862af5d commit 90c41f5
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -738,21 +738,17 @@ class TextInputDelegateTest : BaseSessionTest() {
}

@WithDisplay(width = 512, height = 512) // Child process updates require having a display.
@Test fun sendDummpyKeyboardEvent() {
@Test fun sendDummyKeyboardEvent() {
// unnecessary for designmode
assumeThat("Not in designmode", id, not(equalTo("#designmode")))

mainSession.textInput.view = View(InstrumentationRegistry.getInstrumentation().targetContext)

mainSession.loadTestPath(INPUTS_PATH)
mainSession.waitForPageStop()

textContent = ""
mainSession.evaluateJS("document.querySelector('$id').focus()")
mainSession.waitUntilCalled(GeckoSession.TextInputDelegate::class, "restartInput")
setupContent("")

val ic = mainSession.textInput.onCreateInputConnection(EditorInfo())!!
ic.commitText("a", 1)
assertText("Set initial text", ic, "")

commitText(ic, "foo", 1)
assertTextAndSelectionAt("commit text and selection", ic, "foo", 3)

// Dispatching keydown, input and keyup
val promise =
Expand All @@ -763,7 +759,7 @@ class TextInputDelegateTest : BaseSessionTest() {
{ once: true }) },
{ once: true}))""")
ic.beginBatchEdit();
ic.setSelection(0, 1)
ic.setSelection(0, 3)
ic.setComposingText("", 1)
ic.endBatchEdit()
promise.value
Expand Down

0 comments on commit 90c41f5

Please sign in to comment.