mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Feat: Make it smoother to switch between nearby and explore maps (#6164)
* Nearby: Add 'Show in Explore' 3-dots menu item * MainActivity: Add methods to pass extras between Nearby and Explore * MainActivity: Extend loadFragment() to support passing fragment arguments * Nearby: Add ability to navigate to Explore fragment on 'Show in Explore' click * Explore: Read fragment arguments for Nearby map data and update Explore map if present * Explore: Add 'Show in Nearby' 3-dots menu item. Only visible when Map tab is selected * Explore: On 'Show in Nearby' click, navigate to Nearby fragment, passing map data as fragment args * Nearby: Read fragment arguments for Explore map data and update Nearby map if present * MainActivity: Fix memory leaks when navigating between bottom nav destinations * Explore: Fix crashes caused by unattached map fragment * Refactor code to pass unit tests * Explore: Format javadocs --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
9dc9a3b8ab
commit
7b291535e0
10 changed files with 510 additions and 152 deletions
|
|
@ -11,16 +11,19 @@ import androidx.fragment.app.FragmentManager
|
|||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.nhaarman.mockitokotlin2.eq
|
||||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.contributions.MainActivity
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when`
|
||||
|
|
@ -34,6 +37,7 @@ import org.robolectric.annotation.LooperMode
|
|||
import org.robolectric.fakes.RoboMenu
|
||||
import org.robolectric.fakes.RoboMenuItem
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@LooperMode(LooperMode.Mode.PAUSED)
|
||||
|
|
@ -151,6 +155,14 @@ class ExploreFragmentUnitTest {
|
|||
Shadows.shadowOf(getMainLooper()).idle()
|
||||
val menu: Menu = RoboMenu(context)
|
||||
fragment.onCreateOptionsMenu(menu, inflater)
|
||||
verify(inflater).inflate(R.menu.menu_search, menu)
|
||||
|
||||
val captor = ArgumentCaptor.forClass(
|
||||
Int::class.java
|
||||
)
|
||||
verify(inflater).inflate(captor.capture(), eq(menu))
|
||||
|
||||
val capturedLayout = captor.value
|
||||
assertTrue(capturedLayout == R.menu.menu_search || capturedLayout == R.menu.explore_fragment_menu)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue