SimpleChromeCustomTabsConnection implements Connection, ServiceConnectionCallback { @Override public void onServiceDisconnected() { if (isConnected()) { client.disconnect(); } } SimpleChromeCustomTabsConnection(Binder binder); @Override void connectTo(@NonNull Activity activity); @Override void onServiceConnected(ConnectedClient client); @Override boolean isConnected(); @Override void mayLaunch(Uri uri); @Override Session getSession(); @Override void disconnectFrom(@NonNull Activity activity); @Override boolean isDisconnected(); @Override void onServiceDisconnected();  }
@Test public void givenADisconnectedClient_whenOnServiceDisconnectedIsCalled_thenTheClientDoesnNotDisconnect() { givenADisconnectedClient(); simpleChromeCustomTabsConnection.onServiceDisconnected(); verify(mockConnectedClient, never()).disconnect(); }
@Test public void givenAnAlreadyStartedSession_whenOnServiceDisconnectedIsCalled_thenClientDisconnects() { givenAnAlreadyStartedSession(); simpleChromeCustomTabsConnection.onServiceDisconnected(); verify(mockConnectedClient).disconnect(); }