Skip to content

Commit

Permalink
[b] Attempt to fix Circle CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangphanea committed Jan 10, 2016
1 parent 714eaad commit d5a2096
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ public void testGcmRegistrationHelper_test() throws IOException, InterruptedExce
WaTDAPI mockWaTDAPI = mock(WaTDAPI.class);
APIService.setInstance(mockWaTDAPI);
Call<ResponseModel> mockCall = mock(Call.class);
ArgumentCaptor<Callback> callbackCaptor = ArgumentCaptor.forClass(Callback.class);
when(mockWaTDAPI.createGcmKey(any(CreateGcmKeyRequest.class))).thenReturn(mockCall);
GcmRegistrationHelper.getInstance().register();
GcmRegistrationHelper.getInstance().doRegister();
Thread.sleep(3000);
verify(mockCall).enqueue(callbackCaptor.capture());
callbackCaptor.getValue().onFailure(null);
callbackCaptor.getValue().onResponse(null, null);
verify(mockCall).enqueue(any(Callback.class));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,25 @@ public void setActivity(Activity mActivity) {

public void register() throws IOException {
if (checkPlayService()) {
String registerId = GoogleCloudMessaging.getInstance(mActivity).register("120607825117");
Call<ResponseModel> call = APIService.getInstance().createGcmKey(new CreateGcmKeyRequest(getDeviceId(), registerId));
call.enqueue(new Callback<ResponseModel>() {
@Override
public void onResponse(Response<ResponseModel> response, Retrofit retrofit) {
Log.e("register GCM", "success");
}
doRegister();
}
}

public void doRegister() throws IOException {
String registerId = GoogleCloudMessaging.getInstance(mActivity).register("120607825117");
Call<ResponseModel> call = APIService.getInstance().createGcmKey(new CreateGcmKeyRequest(getDeviceId(), registerId));
call.enqueue(new Callback<ResponseModel>() {
@Override
public void onResponse(Response<ResponseModel> response, Retrofit retrofit) {
Log.e("register GCM", "success");
}

@Override
public void onFailure(Throwable t) {
Log.e("register GCM", "failed");
@Override
public void onFailure(Throwable t) {
Log.e("register GCM", "failed");

}
});
}
}
});
}

private boolean checkPlayService() {
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ machine:
ADB_INSTALL_TIMEOUT : 40
dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter "build-tools-23.0.1"
- echo y | sudo /usr/local/android-sdk-linux/tools/android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository
- chmod +x $APP_HOME/gradlew
test:
override:
Expand Down

0 comments on commit d5a2096

Please sign in to comment.