SimpleChromeCustomTabsConnection implements Connection, ServiceConnectionCallback { @Override public void onServiceConnected(ConnectedClient client) { this.client = client; if (isConnected()) { session = client.newSession(); warmUpPendingUrlIfAny(); } } 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 givenAConnectedClient_whenOnServiceConnectedIsCalled_thenClientStartsNewSession() { givenAConnectedClient(); simpleChromeCustomTabsConnection.onServiceConnected(mockConnectedClient); verify(mockConnectedClient).newSession(); }
@Test public void givenADisconnectedClient_whenOnServiceConnectedIsCalled_thenClientDoesNotStartNewSession() { givenADisconnectedClient(); simpleChromeCustomTabsConnection.onServiceConnected(mockConnectedClient); verify(mockConnectedClient, never()).newSession(); }