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)); }
if (getAction() != other.getAction()) { if (getAction() != null) { if (!getAction().equals(other.getAction())) { return false; if (!other.getAction().equals(getAction())) { return false; if (getData() != other.getData()) { if (getData() != null) { if (!getData().equals(other.getData())) { return false; if (!other.getData().equals(getData())) { return false; if (getType() != other.getType()) { if (getType() != null) { if (!getType().equals(other.getType())) { return false; if (!other.getType().equals(getType())) { return false; if (getPackage() != other.getPackage()) { if (getPackage() != null) { if (!getPackage().equals(other.getPackage())) { return false;
boolean intentsMatch = shadowOf(expectedIntent).getIntentClass().equals(shadowIntent.getIntentClass()); if (!intentsMatch) { message += "started " + actualStartedIntent; } else { Set<String> keys = shadowIntent.getExtras().keySet(); Set<String> expectedKeys = shadowOf(expectedIntent).getExtras().keySet(); intentsMatch = keys.equals(expectedKeys); if(!intentsMatch){
loginButton.callOnClick(); Intent startedIntent = shadowOf(activity).getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertEquals(NextActivity.class.getName(), shadowIntent.getIntentClass());
public void __constructor__(String action) { __constructor__(action, null); }
loginButton.callOnClick(); Intent startedIntent = shadowOf(activity).getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertEquals(NextActivity.class.getName(), shadowIntent.getIntentClass());
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()));
ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName(), equalTo(targetActivityName));
@Test public void shouldDisplayDetailActivityWhenAdapterClicked() throws Exception{ List<ImageNode> nodes = new ArrayList<ImageNode>(); ImageNode node = new ImageNode(); node.setId(36597698); node.setContributorId("halfpoint"); node.setFileName("halfpoint150200457"); node.setFolder("halfpoint1502"); node.setDescription("halfpoint1502"); node.setMediaType("halfpoint1502"); node.setUrlThumb(URLHelper.buildThumbUrl( node.getId(), node.getContributorId(), node.getFolder(), node.getFileName(), node.getDescription())); node.setUrlFullSize(URLHelper.buildFullSizeUrl(node.getUrlThumb())); nodes.add(node); DetailLikeBoxAdapter mAdapter = new DetailLikeBoxAdapter(activity, nodes); GridView gridView = (GridView) activity.findViewById(R.id.likebox_gridview); gridView.setAdapter(mAdapter); View itemView = mAdapter.getView(0, null, gridView); gridView.performItemClick(itemView, 0, mAdapter.getItemId(0)); Intent startedIntent = shadowOf(activity).getNextStartedActivity(); ShadowIntent shadowIntent = shadowOf(startedIntent); // create shadow intent which starts next activity System.out.println(DetailActivity.class.getName()+" "+shadowIntent.getComponent().getClassName() ); assertEquals(DetailActivity.class.getName(), shadowIntent.getComponent().getClassName()); // compare shadow intent w/ desired next activity }