@Override
        public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) {
            mSession = client.newSession(null);
            mConnectionLatch.countDown();
        }
TestRule that helps establishing a connection to CustomTabsService.
customtabs/tests/src/android/support/customtabs/testutil/CustomTabConnectionRule.java