DownloadMapResourceTask extends DownloadTask<Void, Void, String> { @Override protected String doInBackground(Void... params) { String resourceXml = null; try { resourceXml = getXml(mapName); parseBoundingBox(resourceXml); parseZoomLevels(resourceXml); publishResourceData(); } catch (IOException e) { Log.e(TAG, "Failed to download tileMapResource.xml: " + e); success = false; } catch (NicException e) { Log.e(TAG, "Failed to download tileMapResource.xml: " + e); success = false; } success = true; return resourceXml; } DownloadMapResourceTask(Activity activity,
                                   MapServerClient mapServerClient,
                                   String mapName,
                                   IndoorMap map,
                                   DownloadListener<String> listener);  DownloadMapResourceTask(Activity activity,
                                   MapServerClient mapServerClient,
                                   MapView mapView,
                                   String mapName);  static final int MIN_ZOOM_LEVEL_PLUS; }
@Test public void testEmptyXMLMapView() throws NicException, IOException { when(clientMock.getTilemapresourceXml("myMap")).thenReturn(""); DownloadMapResourceTask task = new DownloadMapResourceTask(null, clientMock, mapViewMock, "myMap"); task.doInBackground(); verifyZeroInteractions(mapViewMock); verifyZeroInteractions(indoorMapMock); }
@Test public void testEmptyXMLIndoorMap() throws NicException, IOException { when(clientMock.getTilemapresourceXml("myMap")).thenReturn(""); DownloadMapResourceTask task = new DownloadMapResourceTask(null, clientMock, "myMap", indoorMapMock, null); task.doInBackground(); verifyZeroInteractions(indoorMapMock); }
@Test public void testValidXMLIndoorMap() throws NicException, IOException { when(clientMock.getTilemapresourceXml("myMap")).thenReturn(xml); ArgumentCaptor<BoundingBoxE6> boxCaptor = ArgumentCaptor.forClass(BoundingBoxE6.class); DownloadMapResourceTask task = new DownloadMapResourceTask(null, clientMock, "myMap", indoorMapMock, null); task.doInBackground(); int z =17+DownloadMapResourceTask.MIN_ZOOM_LEVEL_PLUS; verify(indoorMapMock).setZoomLevels(17+DownloadMapResourceTask.MIN_ZOOM_LEVEL_PLUS, 21); BoundingBoxE6 boxIn = new BoundingBoxE6(50722660, 7062209, 50721409, 7060910); verify(indoorMapMock).setBoundingBox(boxCaptor.capture()); BoundingBoxE6 boxOut = boxCaptor.getValue(); assertEquals(boxIn.getLatNorthE6(), boxOut.getLatNorthE6()); assertEquals(boxIn.getLonEastE6(), boxOut.getLonEastE6()); assertEquals(boxIn.getLatSouthE6(), boxOut.getLatSouthE6()); assertEquals(boxIn.getLonWestE6(), boxOut.getLonWestE6()); }