MBTilesHelper { public void initializeMbTileslayers(@NonNull Style style, List<File> offlineFiles) { init(offlineFiles); for (File file : offlineFiles) { String name = file.getName(); if (name.endsWith(MB_TILES_EXTENSION)) { String id = name.substring(0, name.length() - MB_TILES_EXTENSION.length()); addMbtiles(style, id, file); } } }  void initializeMbTileslayers(@NonNull Style style, List<File> offlineFiles); Pair<Set<Source>, Set<Layer>> initializeMbTileslayers(File offlineFile); void setMBTileLayers(Context context, BaseLayerSwitcherPlugin baseLayerSwitcherPlugin); void onDestroy(); static final String MB_TILES_EXTENSION; static final String MB_TILES_DIRECTORY; }
@Test public void testInitializeMbTilesLayersWithVectorTiles() { List<File> offlineFiles = Collections.singletonList(new File("src/test/resources/trails.mbtiles")); mbTilesHelper.initializeMbTileslayers(style, offlineFiles); assertNotNull(mbTilesHelper.tileServer); verify(style).addLayer(any(FillLayer.class)); verify(style).addLayer(any(LineLayer.class)); verify(style).addSource(any(Source.class)); }
@Test public void testInitializeMbTilesLayersWithRasterTiles() { List<File> offlineFiles = Collections.singletonList(new File("src/test/resources/raster.mbtiles")); mbTilesHelper.initializeMbTileslayers(style, offlineFiles); assertNotNull(mbTilesHelper.tileServer); verify(style).addLayer(any(RasterLayer.class)); verify(style).addSource(any(Source.class)); }
@Test public void testInitializeMbTilesLayersWithSingleFile() { Pair<Set<Source>, Set<Layer>> layersAndSources = mbTilesHelper.initializeMbTileslayers(new File("src/test/resources/raster.mbtiles")); assertNotNull(layersAndSources); assertEquals(1, layersAndSources.first.size()); assertEquals(1, layersAndSources.second.size()); assertNotNull(mbTilesHelper.tileServer); Source source = layersAndSources.first.iterator().next(); Layer layer = layersAndSources.second.iterator().next(); assertTrue(source instanceof RasterSource); assertTrue(layer instanceof RasterLayer); }