Java 类org.robolectric.DefaultTestLifecycle 实例源码

项目:FullRobolectricTestSample    文件:ApplicationTest.java   
@Test
public void startActivity_whenActivityCheckingEnabled_checksPackageManagerResolveInfo() throws Exception {
  Application application = new DefaultTestLifecycle().createApplication(null,
      newConfigWith("com.wacka.wa", ""));
  shadowOf(application).checkActivities(true);

  String action = "com.does.not.exist.android.app.v2.mobile";

  try {
    application.startActivity(new Intent(action));
    fail("Expected startActivity to throw ActivityNotFoundException!");
  } catch (ActivityNotFoundException e) {
    assertThat(e.getMessage()).contains(action);
    assertThat(shadowOf(application).getNextStartedActivity()).isNull();
  }
}
项目:FullRobolectricTestSample    文件:ApplicationTest.java   
@Test
public void shouldBeAbleToResetResources() throws Exception {
  Application application = new DefaultTestLifecycle().createApplication(null,
      newConfigWith("com.wacka.wa", ""));
  Resources res = application.getResources();
  shadowOf(application).resetResources();
  assertFalse(res == application.getResources());
}
项目:FullRobolectricTestSample    文件:ApplicationTest.java   
@Test
public void checkPermission_shouldTrackGrantedAndDeniedPermissions() throws Exception {
  Application application = new DefaultTestLifecycle().createApplication(null,
      newConfigWith("com.wacka.wa", ""));
  shadowOf(application).grantPermissions("foo", "bar");
  shadowOf(application).denyPermissions("foo", "qux");
  assertThat(application.checkPermission("foo", -1, -1)).isEqualTo(PERMISSION_DENIED);
  assertThat(application.checkPermission("bar", -1, -1)).isEqualTo(PERMISSION_GRANTED);
  assertThat(application.checkPermission("baz", -1, -1)).isEqualTo(PERMISSION_DENIED);
  assertThat(application.checkPermission("qux", -1, -1)).isEqualTo(PERMISSION_DENIED);
}
项目:FullRobolectricTestSample    文件:ActivityTest.java   
@Test
public void shouldRetrievePackageNameFromTheManifest() throws Exception {
  AndroidManifest appManifest = newConfigWith("com.wacka.wa", "");
  Robolectric.application = new DefaultTestLifecycle().createApplication(null, appManifest);
  shadowOf(application).bind(appManifest, null);

  assertThat("com.wacka.wa").isEqualTo(new Activity().getPackageName());
}
项目:FullRobolectricTestSample    文件:ApplicationTest.java   
@Test
public void shouldRememberResourcesAfterLazilyLoading() throws Exception {
  Application application = new DefaultTestLifecycle().createApplication(null, newConfigWith("com.wacka.wa", ""));
  assertSame(application.getResources(), application.getResources());
}
项目:FullRobolectricTestSample    文件:ContentResolverTest.java   
@Test
public void getProvider_shouldNotReturnAnyProviderWhenManifestIsNull() {
  Robolectric.application = new DefaultTestLifecycle().createApplication(null, null);
  assertThat(ShadowContentResolver.getProvider(Uri.parse("content://"))).isNull();
}
项目:Oleaster    文件:OleasterRobolectricRunner.java   
/**
 * An instance of the returned class will be created for each test invocation.
 *
 * Custom TestRunner subclasses may wish to override this method to provide alternate configuration.
 *
 * @return a class which implements {@link TestLifecycle}. This implementation returns a {@link DefaultTestLifecycle}.
 */
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return DefaultTestLifecycle.class;
}