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:
Arin Modi 2022-03-16 18:09:54 +05:30 committed by GitHub
parent 332a69fe5c
commit 7bc78f67ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 3 deletions

View file

@ -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)
}
}