Fix Crash Edit Categories Fragment (#5510)

* fix crash

* Tests Added

* Tests and Null Checks Added
This commit is contained in:
Shashank Kumar 2024-02-26 15:12:51 +05:30 committed by GitHub
parent 535792390e
commit f5a5159f8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 10 deletions

View file

@ -4,6 +4,7 @@ import android.app.ProgressDialog
import android.content.Context
import android.os.Looper
import android.text.Editable
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
@ -116,7 +117,6 @@ class UploadCategoriesFragmentUnitTests {
Whitebox.setInternalState(fragment, "pbCategories", pbCategories)
Whitebox.setInternalState(fragment, "tilContainerEtSearch", tilContainerEtSearch)
Whitebox.setInternalState(fragment, "adapter", adapter)
Whitebox.setInternalState(fragment, "callback", callback)
Whitebox.setInternalState(fragment, "presenter", presenter)
Whitebox.setInternalState(fragment, "etSearch", etSearch)
Whitebox.setInternalState(fragment, "rvCategories", rvCategories)
@ -365,4 +365,15 @@ class UploadCategoriesFragmentUnitTests {
method.invoke(fragment)
}
}
@Test
@Throws(Exception::class)
fun `Test init when callback is null`() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
val method: Method = UploadCategoriesFragment::class.java.getDeclaredMethod(
"init"
)
method.isAccessible = true
method.invoke(fragment)
}
}