/** * Checks to see if {@code BroadcastListener}s are still registered. * * @throws RuntimeException if any listeners are still registered * @see #assertNoBroadcastListenersRegistered() */ @Implementation public void onDestroy() { assertNoBroadcastListenersRegistered(); }
@Implementation public void onBackPressed() { finish(); }
@Override @Implementation public final Application getApplicationContext() { return getApplication(); }
/** * Checks the {@code ApplicationContext} to see if {@code BroadcastListener}s are still registered. * * @throws RuntimeException if any listeners are still registered * @see ShadowApplication#assertNoBroadcastListenersRegistered(android.content.Context, String) */ public void assertNoBroadcastListenersRegistered() { shadowOf(getApplicationContext()).assertNoBroadcastListenersRegistered(realActivity, "Activity"); }
@Implementation public void setTitle(int titleId) { this.title = this.getResources().getString(titleId); }
/** * Sets the {@code contentView} for this {@code Activity} by invoking the * {@link android.view.LayoutInflater} * * @param layoutResID ID of the layout to inflate * @see #getContentView() */ @Implementation public void setContentView(int layoutResID) { contentView = getLayoutInflater().inflate(layoutResID, new FrameLayout(realActivity)); realActivity.onContentChanged(); }
public Intent getStartedActivityIntent() { return Robolectric.shadowOf(getActivity()) .getNextStartedActivity(); // if (mMockParent != null) { // return mMockParent.mStartedActivityIntent; // } // return null; }
public int getStartedActivityRequest() { return Robolectric.shadowOf(getActivity()) .getNextStartedActivityForResult().requestCode; // if (mMockParent != null) { // return mMockParent.mStartedActivityRequest; // } // return 0; }
public int getRequestedOrientation() { return Robolectric.shadowOf(getActivity()) .getRequestedOrientation(); // if (mMockParent != null) { // return mMockParent.mRequestedOrientation; // } // return 0; }
/** * Checks to ensure that the{@code contentView} has been set * * @param id ID of the view to find * @return the view * @throws RuntimeException if the {@code contentView} has not been called first */ @Implementation public View findViewById(int id) { if (id == android.R.id.content) { return getContentViewContainer(); } if (contentView != null) { return contentView.findViewById(id); } else { System.out.println("WARNING: you probably should have called setContentView() first"); Thread.dumpStack(); return null; } }
@Implementation public void startActivityForResult(Intent intent, int requestCode) { intentRequestCodeMap.put(intent, requestCode); startedActivitiesForResults.add(new IntentForResult(intent, requestCode)); getApplicationContext().startActivity(intent); }
@Implementation public SharedPreferences getPreferences(int mode) { return ShadowPreferenceManager.getDefaultSharedPreferences(getApplicationContext()); }