Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
pengdev committed Sep 24, 2021
1 parent fceee3a commit 2efee62
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class MapChangeReceiverTest {
@Mock
private MapView.OnDidFailLoadingMapListener onDidFailLoadingMapListener;

@Mock
private MapView.OnDidFailLoadingTileListener onDidFailLoadingTileListener;

@Mock
private MapView.OnWillStartRenderingFrameListener onWillStartRenderingFrameListener;

Expand Down Expand Up @@ -314,6 +317,36 @@ public void testOnDidFailLoadingMapListener() {
}
}

@Test
public void testOnDidFailLoadingTileListener() {
mapChangeEventManager.addOnDidFailLoadingTileListener(onDidFailLoadingTileListener);
mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
verify(onDidFailLoadingTileListener).onDidFailLoadingTile(TEST_STRING);
mapChangeEventManager.removeOnDidFailLoadingTileListener(onDidFailLoadingTileListener);
mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
verify(onDidFailLoadingTileListener).onDidFailLoadingTile(TEST_STRING);

mapChangeEventManager.addOnDidFailLoadingTileListener(onDidFailLoadingTileListener);
Logger.setLoggerDefinition(loggerDefinition);
Exception exc = new RuntimeException();
doThrow(exc).when(onDidFailLoadingTileListener).onDidFailLoadingTile(TEST_STRING);
try {
mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
Assert.fail("The exception should've been re-thrown.");
} catch (RuntimeException throwable) {
verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
}

Error err = new ExecutionError("", new Error());
doThrow(err).when(onDidFailLoadingTileListener).onDidFailLoadingTile(TEST_STRING);
try {
mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
Assert.fail("The exception should've been re-thrown.");
} catch (ExecutionError throwable) {
verify(loggerDefinition).e(anyString(), anyString(), eq(err));
}
}

@Test
public void testOnWillStartRenderingFrameListener() {
mapChangeEventManager.addOnWillStartRenderingFrameListener(onWillStartRenderingFrameListener);
Expand Down

0 comments on commit 2efee62

Please sign in to comment.