mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Pass unit tests
This commit is contained in:
parent
b02fe08988
commit
5bdaafad56
4 changed files with 28 additions and 16 deletions
|
|
@ -8,6 +8,7 @@ import fr.free.nrw.commons.kvstore.JsonKvStore;
|
|||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType;
|
||||
import fr.free.nrw.commons.nearby.Label;
|
||||
import fr.free.nrw.commons.nearby.MarkerPlaceGroup;
|
||||
import fr.free.nrw.commons.nearby.Place;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ public interface NearbyParentFragmentContract {
|
|||
|
||||
Context getContext();
|
||||
|
||||
void updateMapMarkers(List<BaseMarker> BaseMarkers);
|
||||
void replaceMarkerOverlays(List<MarkerPlaceGroup> markerPlaceGroups);
|
||||
|
||||
void filterOutAllMarkers();
|
||||
|
||||
|
|
|
|||
|
|
@ -1709,13 +1709,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapMarkers(final List<BaseMarker> BaseMarkers) {
|
||||
if (binding.map != null) {
|
||||
presenter.updateMapMarkersToController(BaseMarkers);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filterOutAllMarkers() {
|
||||
clearAllMarkers();
|
||||
|
|
@ -1739,7 +1732,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
replaceMarkerOverlays(NearbyController.markerLabelList);
|
||||
return;
|
||||
}
|
||||
ArrayList<MarkerPlaceGroup> placeGroupsToShow = new ArrayList<>();
|
||||
final ArrayList<MarkerPlaceGroup> placeGroupsToShow = new ArrayList<>();
|
||||
for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
final Place place = markerPlaceGroup.getPlace();
|
||||
// When label filter is engaged
|
||||
|
|
@ -1891,6 +1884,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* @param markerPlaceGroups The list of marker place groups containing the places and
|
||||
* their bookmarked status
|
||||
*/
|
||||
@Override
|
||||
public void replaceMarkerOverlays(final List<MarkerPlaceGroup> markerPlaceGroups) {
|
||||
ArrayList<Marker> newMarkers = new ArrayList<>(markerPlaceGroups.size());
|
||||
for (MarkerPlaceGroup markerPlaceGroup : markerPlaceGroups) {
|
||||
|
|
|
|||
|
|
@ -162,9 +162,12 @@ class NearbyParentFragmentPresenter
|
|||
/**
|
||||
* Sets click listeners of FABs, and 2 bottom sheets
|
||||
*/
|
||||
override fun setActionListeners(applicationKvStore: JsonKvStore) {
|
||||
override fun setActionListeners(applicationKvStore: JsonKvStore?) {
|
||||
nearbyParentFragmentView.setFABPlusAction(View.OnClickListener { v: View? ->
|
||||
if (applicationKvStore.getBoolean("login_skipped", false)) {
|
||||
if (applicationKvStore != null && applicationKvStore.getBoolean(
|
||||
"login_skipped", false
|
||||
)
|
||||
) {
|
||||
// prompt the user to login
|
||||
nearbyParentFragmentView.displayLoginSkippedWarning()
|
||||
} else {
|
||||
|
|
@ -497,8 +500,15 @@ class NearbyParentFragmentPresenter
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the supplied markerPlaceGroups to `NearbyController` and nearby list fragment,
|
||||
* and tells nearby parent fragment to filter the updated values to be rendered as overlays
|
||||
* on the map
|
||||
*
|
||||
* @param markerPlaceGroups the new/updated list of places along with their bookmarked status
|
||||
*/
|
||||
@MainThread
|
||||
fun updatePlaceGroupsToControllerAndRender(markerPlaceGroups: List<MarkerPlaceGroup>) {
|
||||
private fun updatePlaceGroupsToControllerAndRender(markerPlaceGroups: List<MarkerPlaceGroup>) {
|
||||
NearbyController.markerLabelList.clear()
|
||||
NearbyController.markerLabelList.addAll(markerPlaceGroups)
|
||||
nearbyParentFragmentView.setFilterState()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@ class NearbyParentFragmentPresenterTest {
|
|||
@Mock
|
||||
internal lateinit var bookmarkLocationsDao: BookmarkLocationsDao
|
||||
|
||||
@Mock
|
||||
internal lateinit var placesRepository: PlacesRepository
|
||||
|
||||
@Mock
|
||||
internal lateinit var nearbyController: NearbyController
|
||||
|
||||
@Mock
|
||||
internal lateinit var latestLocation: LatLng
|
||||
|
||||
|
|
@ -52,7 +58,8 @@ class NearbyParentFragmentPresenterTest {
|
|||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
nearbyPresenter = NearbyParentFragmentPresenter(bookmarkLocationsDao)
|
||||
nearbyPresenter =
|
||||
NearbyParentFragmentPresenter(bookmarkLocationsDao, placesRepository, nearbyController)
|
||||
nearbyPresenter.attachView(nearbyParentFragmentView)
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +329,7 @@ class NearbyParentFragmentPresenterTest {
|
|||
|
||||
@Test
|
||||
fun testSetActionListeners() {
|
||||
nearbyPresenter.setActionListeners(any())
|
||||
nearbyPresenter.setActionListeners(null)
|
||||
verify(nearbyParentFragmentView).setFABPlusAction(any())
|
||||
verify(nearbyParentFragmentView).setFABRecenterAction(any())
|
||||
}
|
||||
|
|
@ -454,11 +461,11 @@ class NearbyParentFragmentPresenterTest {
|
|||
nearbyPlacesInfo.boundaryCoordinates = arrayOf()
|
||||
nearbyPlacesInfo.currentLatLng = latestLocation
|
||||
nearbyPlacesInfo.searchLatLng = latestLocation
|
||||
nearbyPlacesInfo.placeList = null
|
||||
nearbyPlacesInfo.placeList = emptyList<Place>()
|
||||
|
||||
whenever(bookmarkLocationsDao.allBookmarksLocations).thenReturn(Collections.emptyList())
|
||||
nearbyPresenter.updateMapMarkers(nearbyPlacesInfo.placeList, latestLocation, null)
|
||||
Mockito.verify(nearbyParentFragmentView).updateMapMarkers(any())
|
||||
Mockito.verify(nearbyParentFragmentView).setFilterState()
|
||||
Mockito.verify(nearbyParentFragmentView).setProgressBarVisibility(false)
|
||||
Mockito.verify(nearbyParentFragmentView).updateListFragment(nearbyPlacesInfo.placeList)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue