public static void assertButtonClickLaunchesActivity(Activity activity, Button btn, String targetActivityName) { btn.performClick(); ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName(), equalTo(targetActivityName)); }
@Override public void applyAttributes() { super.applyAttributes(); applyTextAttribute(); applyTextColorAttribute(); applyHintAttribute(); applyHintColorAttribute(); applyCompoundDrawablesWithIntrinsicBoundsAttributes(); }
@Override public void applyAttributes() { super.applyAttributes(); if (getBackground() == null) { setBackgroundColor(android.R.color.transparent); } } }
public void create() { final ActivityInvoker invoker = new ActivityInvoker(); final Bundle noInstanceState = null; invoker.call("onCreate", Bundle.class).with(noInstanceState); invoker.call("onStart").withNothing(); invoker.call("onPostCreate", Bundle.class).with(noInstanceState); invoker.call("onResume").withNothing(); }
/** * Return (without consuming) the next {@code Intent} on the started services stack. * * @return the next started {@code Intent} for a service */ public Intent peekNextStartedService() { return getShadowApplication().peekNextStartedService(); }
@Override public void applyAttributes() { super.applyAttributes(); applyImageAttribute(); }
private void update() { if (!automaticallyUpdateRowViews) { return; } super.removeAllViews(); addViews(); }
/** * Non-Android accessor that delegates to the application to consume and return the next {@code Intent} on the * started activities stack. * * @return the next started {@code Intent} for an activity */ public Intent getNextStartedActivity() { return getShadowApplication().getNextStartedActivity(); }
/** * Non-Android accessor that delegates to the application to return (without consuming) the next {@code Intent} on * the started activities stack. * * @return the next started {@code Intent} for an activity */ public Intent peekNextStartedActivity() { return getShadowApplication().peekNextStartedActivity(); }
/** * Non-Android accessor that delegates to the application to return the next {@code Intent} to stop * a service (irrespective of if the service was running) * * @return {@code Intent} for the next service requested to be stopped */ public Intent getNextStoppedService() { return getShadowApplication().getNextStoppedService(); }
/** * Non-Android accessor that delegates to the application to consume and return the next {@code Intent} on the * started services stack. * * @return the next started {@code Intent} for a service */ public Intent getNextStartedService() { return getShadowApplication().getNextStartedService(); }
/** * Non-android accessor that delefates to the application to clear the stack of started * service intents. */ public void clearStartedServices() { getShadowApplication().clearStartedServices(); }
@Override public void onChanged() { mDataValid = true; notifyDataSetChanged(); }
/** * Accessor to obtain HTTP requests made during the current test in the order in which they were made. * * @param index index of the request to retrieve. * @return the requested request. */ public static HttpRequest getSentHttpRequest(int index) { return ShadowDefaultRequestDirector.getSentHttpRequest(index); }
/** * Constructor. The adapter will call requery() on the cursor whenever * it changes so that the most recent data is always displayed. * * @param c The cursor from which to get the data. * @param context The context */ public void __constructor__(Context context, Cursor c) { initialize(context, c, true); }
/** * Non-Android accessor used for creating ResolveInfo objects * @param displayName * @param packageName * @return */ public static ResolveInfo newResolveInfo( String displayName, String packageName ) { return newResolveInfo( displayName, packageName, null); }
MenuItem item = new TestMenuItem() { public int getItemId() { return R.id.hello; } }; activity.onOptionsItemSelected(item); ShadowActivity shadowActivity = Robolectric.shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = Robolectric.shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName(), equalTo(HelloActivity_.class.getName()));
// Get shadow ShadowActivity shadowActivity = Shadows.shadowOf(activity); // Click menu shadowActivity.clickMenuItem(R.id.settings_option_item); // Get intent Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent); // Make your assertion assertThat(shadowIntent.getComponent().getClassName(), equalTo(HelloActivity_.class.getName()));