mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
[Contributions-Tab] Scroll to top on NavBar Button Pressed (#4668)
* [Contributions-Tab] Scroll to top on NavBar Button Pressed On NavBar Contributions Button pressed, if already on the Contributions tab, scroll to the top of the recyclerView in ContributionsListFragment. * [UnitTest][Contributions-Tab] Scroll to Top on NavBar Button Pressed
This commit is contained in:
parent
88b21a678e
commit
55c0b07ebf
6 changed files with 47 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ import org.junit.runner.RunWith
|
|||
import org.mockito.ArgumentMatchers.*
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.reflect.Whitebox
|
||||
import org.robolectric.Robolectric
|
||||
|
|
@ -217,6 +218,14 @@ class ContributionsFragmentUnitTests {
|
|||
fragment.updateLimitedConnectionToggle(menu)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testScrollToTop(){
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.scrollToTop()
|
||||
verify(contributionsListFragment).scrollToTop()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnAttach() {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.junit.runner.RunWith
|
|||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.reflect.Whitebox
|
||||
import org.robolectric.Robolectric
|
||||
|
|
@ -160,6 +161,14 @@ class ContributionsListFragmentUnitTests {
|
|||
fragment.getContributionStateAt(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnScrollToTop() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.scrollToTop()
|
||||
verify(rvContributionsList).smoothScrollToPosition(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnConfirmClicked() {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.robolectric.Robolectric
|
||||
|
|
@ -243,6 +244,21 @@ class MainActivityUnitTests {
|
|||
method.invoke(activity, contributionsFragment, false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testLoadFragmentCaseContributionsFragmentCaseTrue() {
|
||||
activeFragment = ActiveFragment.CONTRIBUTIONS
|
||||
activity.activeFragment = activeFragment
|
||||
val method: Method = MainActivity::class.java.getDeclaredMethod(
|
||||
"loadFragment",
|
||||
Fragment::class.java,
|
||||
Boolean::class.java
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, contributionsFragment, false)
|
||||
verify(contributionsFragment).scrollToTop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testLoadFragmentCaseNearbyParentFragmentCaseTrue() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue