SimpleChromeCustomTabsConnection implements Connection, ServiceConnectionCallback { @Override public void mayLaunch(Uri uri) { if (isEmpty(uri)) { return; } if (hasActiveSession()) { session.mayLaunch(uri); } else { pendingUrlToWarmUp = uri; } } 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 givenAnAlreadyStartedSession_whenMayLaunchIsCalled_thenUrlIsWarmedUp() { givenAnAlreadyStartedSession(); simpleChromeCustomTabsConnection.mayLaunch(ANY_URI); verify(mockSession).mayLaunch(ANY_URI); }
@Test public void givenAnAlreadyStartedSession_andAnEmptyUrl_whenMayLaunchIsCalled_thenUrlIsNotWarmedUp() { givenAnAlreadyStartedSession(); simpleChromeCustomTabsConnection.mayLaunch(Uri.EMPTY); verifyZeroInteractions(mockSession); }
@Test public void givenAnAlreadyStartedSession_andAnNullUrl_whenMayLaunchIsCalled_thenUrlIsNotWarmedUp() { givenAnAlreadyStartedSession(); simpleChromeCustomTabsConnection.mayLaunch(null); verifyZeroInteractions(mockSession); }
@Test public void givenASessionIsNotStarted_whenMayLaunchIsCalled_thenUrlIsNotWarmedUp() { givenASessionIsNotStarted(); simpleChromeCustomTabsConnection.mayLaunch(ANY_URI); verifyZeroInteractions(mockSession); }