mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Removed butterknife from login activity (#5380)
* Removed butterknife view bindings * Migrated click listeners to view binding * Migrate onEditorAction to use ViewBinding * Finally, removed butterknife
This commit is contained in:
parent
9620f6eee0
commit
861d2b9bf6
2 changed files with 56 additions and 110 deletions
|
|
@ -10,6 +10,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestAppAdapter
|
||||
|
|
@ -55,7 +56,7 @@ class LoginActivityUnitTests {
|
|||
private lateinit var keyEvent: KeyEvent
|
||||
|
||||
@Mock
|
||||
private lateinit var loginButton: Button
|
||||
private lateinit var textView: TextView
|
||||
|
||||
@Mock
|
||||
private lateinit var bundle: Bundle
|
||||
|
|
@ -95,40 +96,12 @@ class LoginActivityUnitTests {
|
|||
fun testOnEditorActionCaseDefault() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onEditorAction",
|
||||
TextView::class.java,
|
||||
Int::class.java,
|
||||
KeyEvent::class.java
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, 0, keyEvent)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnEditorActionCaseLoginEnabledFirstCase() {
|
||||
Whitebox.setInternalState(activity, "loginButton", loginButton)
|
||||
`when`(loginButton.isEnabled).thenReturn(true)
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onEditorAction",
|
||||
Int::class.java,
|
||||
KeyEvent::class.java
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, EditorInfo.IME_ACTION_DONE, keyEvent)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnEditorActionCaseLoginEnabledSecondCase() {
|
||||
Whitebox.setInternalState(activity, "loginButton", loginButton)
|
||||
`when`(loginButton.isEnabled).thenReturn(true)
|
||||
`when`(keyEvent.keyCode).thenReturn(KeyEvent.KEYCODE_ENTER)
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onEditorAction",
|
||||
Int::class.java,
|
||||
KeyEvent::class.java
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, 0, keyEvent)
|
||||
method.invoke(activity, textView, 0, keyEvent)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue