Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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
You can’t perform that action at this time.