use of com.facebook.TestBlocker in project facebook-android-sdk by facebook.
the class LoginClientTests method testReauthorizationWithSameFbidSucceeds.
@LargeTest
public void testReauthorizationWithSameFbidSucceeds() throws Exception {
TestBlocker blocker = getTestBlocker();
MockValidatingLoginClient client = new MockValidatingLoginClient(null, blocker);
client.addAccessTokenToFbidMapping(USER_1_ACCESS_TOKEN, USER_1_FBID);
client.addAccessTokenToFbidMapping(USER_2_ACCESS_TOKEN, USER_2_FBID);
client.setPermissionsToReport(PERMISSIONS);
LoginClient.Request request = createNewPermissionRequest();
client.setRequest(request);
AccessToken token = new AccessToken(USER_1_ACCESS_TOKEN, APP_ID, USER_1_FBID, PERMISSIONS, null, null, null, null);
AccessToken.setCurrentAccessToken(token);
LoginClient.Result result = LoginClient.Result.createTokenResult(request, token);
client.completeAndValidate(result);
blocker.waitForSignals(1);
assertNotNull(client.result);
assertEquals(LoginClient.Result.Code.SUCCESS, client.result.code);
AccessToken resultToken = client.result.token;
assertNotNull(resultToken);
assertEquals(USER_1_ACCESS_TOKEN, resultToken.getToken());
// We don't care about ordering.
assertEquals(new HashSet<String>(PERMISSIONS), new HashSet<String>(resultToken.getPermissions()));
}
use of com.facebook.TestBlocker in project facebook-android-sdk by facebook.
the class LoginClientTests method testReauthorizationWithDifferentFbidsFails.
@LargeTest
public void testReauthorizationWithDifferentFbidsFails() throws Exception {
TestBlocker blocker = getTestBlocker();
MockValidatingLoginClient client = new MockValidatingLoginClient(null, blocker);
client.addAccessTokenToFbidMapping(USER_1_ACCESS_TOKEN, USER_1_FBID);
client.addAccessTokenToFbidMapping(USER_2_ACCESS_TOKEN, USER_2_FBID);
client.setPermissionsToReport(PERMISSIONS);
LoginClient.Request request = createNewPermissionRequest();
client.setRequest(request);
AccessToken userOneToken = new AccessToken(USER_1_ACCESS_TOKEN, APP_ID, USER_1_FBID, PERMISSIONS, null, null, null, null);
AccessToken.setCurrentAccessToken(userOneToken);
AccessToken userTwoToken = new AccessToken(USER_2_ACCESS_TOKEN, APP_ID, USER_2_FBID, PERMISSIONS, null, null, null, null);
LoginClient.Result result = LoginClient.Result.createTokenResult(request, userTwoToken);
client.completeAndValidate(result);
blocker.waitForSignals(1);
assertNotNull(client.result);
assertEquals(LoginClient.Result.Code.ERROR, client.result.code);
assertNull(client.result.token);
assertNotNull(client.result.errorMessage);
}
use of com.facebook.TestBlocker in project facebook-android-sdk by facebook.
the class UpdateUserPropertiesTests method testUserUpdateProperties.
public void testUserUpdateProperties() throws Exception {
final TestBlocker blocker = getTestBlocker();
Bundle parameters = new Bundle();
parameters.putString("custom_value", "1");
AppEventsLogger.setUserID("1");
AppEventsLogger.updateUserProperties(parameters, getApplicationId(), new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
blocker.setException(response.getError().getException());
}
blocker.signal();
}
});
blocker.waitForSignals(1);
if (blocker.getException() != null) {
throw blocker.getException();
}
}
Aggregations