LoginActivity extends Activity { void onCodeReceived(Uri uri) { try { String code = AuthUtils.parseAuthorizationCode(uri); setResult(RESULT_OK, new Intent().putExtra(LoginManager.EXTRA_CODE_RECEIVED, code)); finish(); } catch (LoginAuthenticationException loginException) { onError(loginException.getAuthenticationError()); return; } }  @NonNull static Intent newIntent(
            @NonNull Context context,
            @NonNull SessionConfiguration sessionConfiguration,
            @NonNull ResponseType responseType); @NonNull static Intent newIntent(
            @NonNull Context context,
            @NonNull SessionConfiguration sessionConfiguration,
            @NonNull ResponseType responseType,
            boolean forceWebview); static Intent newResponseIntent(Context context, Uri responseUri);  }
@Test public void onCodeReceived_shouldReturnResultIntentWithCode() { ShadowActivity shadowActivity = shadowOf(loginActivity); String redirectUrl = REDIRECT_URI + "?code=" + CODE; loginActivity.onCodeReceived(Uri.parse(redirectUrl)); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultCode()).isEqualTo(Activity.RESULT_OK); assertThat(shadowActivity.getResultIntent().getStringExtra(LoginManager.EXTRA_CODE_RECEIVED)).isEqualTo(CODE); assertThat(shadowActivity.isFinishing()).isTrue(); }