-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent NavigationNotification update after unregistered
- Loading branch information
1 parent
f52ebe7
commit ba02ce6
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
.../mapbox/services/android/navigation/v5/navigation/NavigationNotificationProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.mapbox.services.android.navigation.v5.navigation; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification; | ||
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyZeroInteractions; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class NavigationNotificationProviderTest { | ||
|
||
@Test | ||
public void updateNavigationNotification() { | ||
NavigationNotification notification = mock(NavigationNotification.class); | ||
MapboxNavigation mapboxNavigation = buildNavigationWithNotificationOptions(notification); | ||
Context context = mock(Context.class); | ||
NavigationNotificationProvider provider = new NavigationNotificationProvider(context, mapboxNavigation); | ||
|
||
RouteProgress routeProgress = mock(RouteProgress.class); | ||
provider.updateNavigationNotification(routeProgress); | ||
|
||
verify(notification).updateNotification(eq(routeProgress)); | ||
} | ||
|
||
@Test | ||
public void updateNavigationNotification_doesNotUpdateAfterShutdown() { | ||
NavigationNotification notification = mock(NavigationNotification.class); | ||
MapboxNavigation mapboxNavigation = buildNavigationWithNotificationOptions(notification); | ||
Context context = mock(Context.class); | ||
NavigationNotificationProvider provider = new NavigationNotificationProvider(context, mapboxNavigation); | ||
|
||
provider.shutdown(context); | ||
provider.updateNavigationNotification(mock(RouteProgress.class)); | ||
|
||
verifyZeroInteractions(notification); | ||
} | ||
|
||
@NonNull | ||
private MapboxNavigation buildNavigationWithNotificationOptions(NavigationNotification notification) { | ||
MapboxNavigation mapboxNavigation = mock(MapboxNavigation.class); | ||
MapboxNavigationOptions options = mock(MapboxNavigationOptions.class); | ||
when(options.navigationNotification()).thenReturn(notification); | ||
when(mapboxNavigation.options()).thenReturn(options); | ||
return mapboxNavigation; | ||
} | ||
} |