mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Remember last opened screen on app startup (Nearby or Contributions) (#4881)
* added required changes * Fixed #4808 : Added the feature of opening last opened screen between Contribution & NearBy * removed the unnecessary commits * removed the unnecessary commits * removed the unnecessary commits * removed the unnecessary commits * added test * comments added
This commit is contained in:
parent
332a69fe5c
commit
7bc78f67ff
2 changed files with 42 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.work.Configuration
|
||||
import androidx.work.testing.WorkManagerTestInitHelper
|
||||
|
|
@ -23,6 +24,7 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
|
@ -457,4 +459,26 @@ class MainActivityUnitTests {
|
|||
method.invoke(activity, bundle)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnSetUpPagerNearBy(){
|
||||
val item = Mockito.mock(MenuItem::class.java)
|
||||
`when`(item.title).thenReturn(activity.getString(R.string.nearby_fragment))
|
||||
activity.navListener.onNavigationItemSelected(item)
|
||||
verify(item, Mockito.times(3)).title
|
||||
verify(applicationKvStore,Mockito.times(1))
|
||||
.putBoolean("last_opened_nearby",true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnSetUpPagerOtherThanNearBy(){
|
||||
val item = Mockito.mock(MenuItem::class.java)
|
||||
`when`(item.title).thenReturn(activity.getString(R.string.bookmarks))
|
||||
activity.navListener.onNavigationItemSelected(item)
|
||||
verify(item, Mockito.times(3)).title
|
||||
verify(applicationKvStore,Mockito.times(1))
|
||||
.putBoolean("last_opened_nearby",false)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue