RideRequestActivity extends Activity implements LoginCallback, RideRequestViewCallback { @NonNull public static Intent newIntent(@NonNull Context context, @Nullable RideParameters rideParameters, @NonNull SessionConfiguration loginConfiguration, @Nullable String accessTokenStorageKey) { Intent data = new Intent(context, RideRequestActivity.class); if (rideParameters == null) { rideParameters = new RideParameters.Builder().build(); } data.putExtra(RIDE_PARAMETERS, rideParameters); data.putExtra(EXTRA_LOGIN_CONFIGURATION, loginConfiguration); data.putExtra(EXTRA_ACCESS_TOKEN_STORAGE_KEY, accessTokenStorageKey); return data; }  @NonNull static Intent newIntent(@NonNull Context context,
            @Nullable RideParameters rideParameters,
            @NonNull SessionConfiguration loginConfiguration,
            @Nullable String accessTokenStorageKey); @Override void onCreate(Bundle savedInstanceState); @Override void onErrorReceived(@NonNull RideRequestViewError error); @Override void onLoginCancel(); @Override void onLoginError(@NonNull AuthenticationError error); @Override void onLoginSuccess(@NonNull AccessToken accessToken); @Override void onAuthorizationCodeReceived(@NonNull String authorizationCode); @Override void onRequestPermissionsResult(
            int requestCode,
            @NonNull String[] permissions,
            @NonNull int[] grantResults); static final String AUTHENTICATION_ERROR; static final String RIDE_REQUEST_ERROR; }
@Test public void onNewIntent_withNullRideParameters_shouldGetDefaultParams() { Intent data = RideRequestActivity.newIntent(Robolectric.setupActivity(Activity.class), null, new SessionConfiguration.Builder().setClientId("clientId").build(), null); assertNotNull(data); RideParameters rideParameters = data.getParcelableExtra(RideRequestActivity.RIDE_PARAMETERS); assertNotNull(rideParameters); }
@Test public void onNewIntent_withRideParameters_shouldGetRideParams() { Double PICKUP_LAT = 32.1234; Double PICKUP_LONG = -122.3456; Double DROPOFF_LAT = 32.5678; Double DROPOFF_LONG = -122.6789; RideParameters rideParameters = new RideParameters.Builder() .setPickupLocation(PICKUP_LAT, PICKUP_LONG, null, null) .setDropoffLocation(DROPOFF_LAT, DROPOFF_LONG, null, null) .build(); Intent data = RideRequestActivity.newIntent(Robolectric.setupActivity(Activity.class), rideParameters, new SessionConfiguration.Builder().setClientId("clientId").build(), null); assertNotNull(data); RideParameters resultParameters = data.getParcelableExtra(RideRequestActivity.RIDE_PARAMETERS); assertNotNull(resultParameters); assertEquals(rideParameters.getPickupLatitude(), resultParameters.getPickupLatitude()); assertEquals(rideParameters.getPickupLongitude(), resultParameters.getPickupLongitude()); assertEquals(rideParameters.getDropoffLatitude(), resultParameters.getDropoffLatitude()); assertEquals(rideParameters.getDropoffLongitude(), resultParameters.getDropoffLongitude()); }
@Test public void onLoad_withUserAgentInRideParametersButton_shouldNotGetOverridden() { String userAgent = String.format("rides-android-v%s-button", BuildConfig.VERSION_NAME); RideParameters rideParameters = new RideParameters.Builder().build(); rideParameters.setUserAgent(userAgent); Intent data = RideRequestActivity.newIntent(Robolectric.setupActivity(Activity.class), rideParameters, new SessionConfiguration.Builder().setClientId("clientId").build(), null); activity = Robolectric.buildActivity(RideRequestActivity.class).withIntent(data).create().get(); assertEquals(userAgent, activity.rideRequestView.rideParameters.getUserAgent()); }