Exemplo n.º 1
0
  @Test
  public void recreateGoesThroughFullLifeCycle() throws Exception {
    TestActivity activity = buildActivity(TestActivity.class).attach().get();
    activity.recreate();

    activity.transcript.assertEventsSoFar(
        "onSaveInstanceState",
        "onPause",
        "onStop",
        "onRetainNonConfigurationInstance",
        "onDestroy",
        "onCreate",
        "onStart",
        "onRestoreInstanceState",
        "onResume");

    Integer storedValue = (Integer) activity.getLastNonConfigurationInstance();
    assertEquals(5, storedValue.intValue());
  }
Exemplo n.º 2
0
  @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 = Shadow.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);
  }
Exemplo n.º 3
0
 @Test
 public void setVolumeControlStream_setsTheSpecifiedStreamType() {
   TestActivity activity = new TestActivity();
   activity.setVolumeControlStream(AudioManager.STREAM_ALARM);
   assertThat(activity.getVolumeControlStream()).isEqualTo(AudioManager.STREAM_ALARM);
 }