mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Migrated Review Package to View Binding (#5604)
* Migrated Review Package to View Binding * fix
This commit is contained in:
parent
a45ab9cf16
commit
2a2780a4d2
5 changed files with 90 additions and 109 deletions
|
|
@ -12,6 +12,7 @@ import fr.free.nrw.commons.Media
|
|||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import fr.free.nrw.commons.databinding.ActivityReviewBinding
|
||||
import io.reactivex.Single
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
|
@ -58,6 +59,8 @@ class ReviewActivityTest {
|
|||
@Mock
|
||||
private lateinit var reviewImageFragment: ReviewImageFragment
|
||||
|
||||
private lateinit var binding: ActivityReviewBinding
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
|
@ -71,11 +74,12 @@ class ReviewActivityTest {
|
|||
Fresco.initialize(context)
|
||||
|
||||
activity = Robolectric.buildActivity(ReviewActivity::class.java).create().get()
|
||||
binding = ActivityReviewBinding.inflate(activity.layoutInflater)
|
||||
|
||||
menuItem = RoboMenuItem(null)
|
||||
|
||||
menu = RoboMenu(context)
|
||||
Whitebox.setInternalState(activity, "reviewPager", reviewPager);
|
||||
Whitebox.setInternalState(binding, "viewPagerReview", reviewPager);
|
||||
Whitebox.setInternalState(activity, "hasNonHiddenCategories", hasNonHiddenCategories);
|
||||
Whitebox.setInternalState(activity, "reviewHelper", reviewHelper);
|
||||
Whitebox.setInternalState(activity, "reviewImageFragment", reviewImageFragment);
|
||||
|
|
@ -192,4 +196,4 @@ class ReviewActivityTest {
|
|||
activity.onBackPressed()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import fr.free.nrw.commons.OkHttpConnectionFactory
|
|||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import fr.free.nrw.commons.databinding.FragmentReviewImageBinding
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
|
@ -57,6 +58,8 @@ class ReviewImageFragmentTest {
|
|||
|
||||
private lateinit var activity: ReviewActivity
|
||||
|
||||
private lateinit var binding: FragmentReviewImageBinding
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
|
||||
|
|
@ -78,16 +81,18 @@ class ReviewImageFragmentTest {
|
|||
|
||||
view = LayoutInflater.from(activity)
|
||||
.inflate(R.layout.fragment_review_image, null) as View
|
||||
binding = FragmentReviewImageBinding.inflate(LayoutInflater.from(activity))
|
||||
|
||||
noButton = view.findViewById(R.id.button_no)
|
||||
yesButton = view.findViewById(R.id.button_yes)
|
||||
textViewQuestion = view.findViewById(R.id.tv_review_question)
|
||||
textViewQuestionContext = view.findViewById(R.id.tv_review_question_context)
|
||||
|
||||
fragment.noButton = noButton
|
||||
fragment.yesButton = yesButton
|
||||
fragment.textViewQuestion = textViewQuestion
|
||||
fragment.textViewQuestionContext = textViewQuestionContext
|
||||
Whitebox.setInternalState(fragment, "binding", binding)
|
||||
Whitebox.setInternalState(binding, "buttonYes", yesButton)
|
||||
Whitebox.setInternalState(binding, "buttonNo", noButton)
|
||||
Whitebox.setInternalState(binding, "tvReviewQuestion", textViewQuestion)
|
||||
Whitebox.setInternalState(binding, "tvReviewQuestionContext", textViewQuestionContext)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -159,4 +164,4 @@ class ReviewImageFragmentTest {
|
|||
shadowOf(Looper.getMainLooper()).idle()
|
||||
Assert.assertNotNull(method.invoke(fragment))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue