@Test public void startAndStopManagingCursorTracksCursors() throws Exception { TestActivity activity = new TestActivity(); ShadowActivity shadow = shadowOf(activity); assertThat(shadow.getManagedCursors()).isNotNull(); assertThat(shadow.getManagedCursors().size()).isEqualTo(0); Cursor c = Robolectric.newInstanceOf(SQLiteCursor.class); activity.startManagingCursor(c); assertThat(shadow.getManagedCursors()).isNotNull(); assertThat(shadow.getManagedCursors().size()).isEqualTo(1); assertThat(shadow.getManagedCursors().get(0)).isSameAs(c); activity.stopManagingCursor(c); assertThat(shadow.getManagedCursors()).isNotNull(); assertThat(shadow.getManagedCursors().size()).isEqualTo(0); }
@Test public void recreateGoesThroughFullLifeCycle() throws Exception { TestActivity activity = new TestActivity(); ShadowActivity shadow = shadowOf(activity); shadow.recreate(); activity.transcript.assertEventsSoFar( "onSaveInstanceState", "onPause", "onStop", "onRetainNonConfigurationInstance", "onDestroy", "onCreate", "onStart", "onRestoreInstanceState", "onResume"); Integer storedValue = (Integer) activity.getLastNonConfigurationInstance(); assertEquals(5, storedValue.intValue()); }
@Test public void setVolumeControlStream_setsTheSpecifiedStreamType() { TestActivity activity = new TestActivity(); activity.setVolumeControlStream(AudioManager.STREAM_ALARM); assertThat(activity.getVolumeControlStream()).isEqualTo(AudioManager.STREAM_ALARM); }