MapScreenshotProvider extends BaseScreenshotProvider { @NonNull @VisibleForTesting List<MapView> locateMapViewsInHierarchy(@NonNull final View view) { final List<MapView> result = new ArrayList<>(); final Queue<View> viewsToProcess = new LinkedList<>(); viewsToProcess.add(view); while (!viewsToProcess.isEmpty()) { final View viewToProcess = viewsToProcess.remove(); if (viewToProcess instanceof MapView && viewToProcess.getVisibility() == VISIBLE) { result.add((MapView) viewToProcess); } else if (viewToProcess instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) viewToProcess; for (int childIndex = 0; childIndex < viewGroup.getChildCount(); childIndex++) { viewsToProcess.add(viewGroup.getChildAt(childIndex)); } } } return result; } MapScreenshotProvider(
            @NonNull final Context applicationContext,
            @NonNull final Logger logger); @NonNull @Override Observable<Bitmap> getScreenshotBitmap(@NonNull final Activity activity);  }
@SuppressWarnings("MethodName") @Test public void testThat_noExceptionThrown_when_searchingViewHierarchyThatContainsMultipleViews() { final ViewGroup mockRootView = mock(ViewGroup.class); final int numberOfChildViews = 4; assert numberOfChildViews > 1; when(mockRootView.getChildCount()).thenReturn(numberOfChildViews); when(mockRootView.getChildAt(anyInt())).thenReturn(mock(View.class)); mapScreenshotProvider.locateMapViewsInHierarchy(mockRootView); }