Binder { public void unbindCustomTabsService(@NonNull Context context) { if (isDisconnected()) { return; } try { context.unbindService(serviceConnection); } catch (IllegalArgumentException iae) { Log.e("SimpleChromeCustomTabs", "There was a problem unbinding from a CustomTabs service. :/", iae); } finally { serviceConnection.onServiceDisconnected(null); serviceConnection = null; } } Binder(@NonNull AvailableAppProvider availableAppProvider); void bindCustomTabsServiceTo(@NonNull final Context context, ServiceConnectionCallback callback); void unbindCustomTabsService(@NonNull Context context);  }
@Test public void givenThatActivityIsBoundToServce_whenActivityIsUnboundFromService_thenActivityIsUnbound() { givenThatActivityIsAlreadyBoundtoService(); binder.unbindCustomTabsService(mockActivity); verify(mockActivity).unbindService(any(ServiceConnection.class)); }
@Test public void givenThatActivityIsNotBoundToService_whenActivityIsUnboundFromService_thenNothingHappens() { givenThatActivityIsNotBoundToService(); binder.unbindCustomTabsService(mockActivity); verifyZeroInteractions(mockActivity); }