Skip to content

Instantly share code, notes, and snippets.

@orhanobut
Last active July 3, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orhanobut/83956cb912cf5f2dddab to your computer and use it in GitHub Desktop.
Save orhanobut/83956cb912cf5f2dddab to your computer and use it in GitHub Desktop.
@RunWith(AndroidJUnit4.class)
public class GooglePlacesApiTest {
private GoogleApiClient apiClient;
@Before public void setup() throws InterruptedException {
Context context = InstrumentationRegistery.getContext();
final CountDownLatch latch = new CountDownLatch(1);
apiClient = new GoogleApiClient.Builder(context)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override public void onConnected(Bundle bundle) {
latch.countDown();
}
})
.build();
apiClient.connect();
assertThat(latch.await(3, SECONDS)).isTrue();
}
@Test public void apiClientShouldConnect() {
assertThat(apiClient.isConnected()).isTrue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment