Commit d352fe51 authored by ValentinTimisica's avatar ValentinTimisica
Browse files

For #6295: Adds tests for 'done' action functionality.

parent 25500a79
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package mozilla.components.feature.prompts.ext
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.support.test.robolectric.testContext
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.Mockito.never
@RunWith(AndroidJUnit4::class)
class EditTextTest {
private val onDonePressed: () -> Unit = spy {}
@Test
fun `GIVEN a callback, WHEN action done is performed - IME_ACTION_DONE -, THEN onDonePress should be called`() {
val view = EditText(testContext)
val editorInfo = EditorInfo()
val inputConnection = view.onCreateInputConnection(editorInfo)
view.onDone(false, onDonePressed)
inputConnection.performEditorAction(EditorInfo.IME_ACTION_DONE)
verify(onDonePressed).invoke()
}
@Test
fun `GIVEN a callback, WHEN a different action is performed - IME_ACTION_SEARCH -, THEN onDonePress shouldn't be called `() {
val view = EditText(testContext)
val editorInfo = EditorInfo()
val inputConnection = view.onCreateInputConnection(editorInfo)
view.onDone(false, onDonePressed)
inputConnection.performEditorAction(EditorInfo.IME_ACTION_SEARCH)
verify(onDonePressed, never()).invoke()
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment