Java 类org.robolectric.shadows.ShadowEnvironment 实例源码

项目:commcare-android    文件:FormRecordListActivityTest.java   
private static void launchFormEntryForSavedForm(ShadowActivity homeActivityShadow,
                                                Intent savedFormsIntent,
                                                FormRecordListActivity savedFormsActivity) {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);

    ShadowActivity formRecordShadow = Shadows.shadowOf(savedFormsActivity);
    homeActivityShadow.receiveResult(savedFormsIntent,
            formRecordShadow.getResultCode(),
            formRecordShadow.getResultIntent());
    ShadowActivity.IntentForResult formEntryIntent =
            homeActivityShadow.getNextStartedActivityForResult();
    Robolectric.buildActivity(FormEntryActivity.class)
                    .withIntent(formEntryIntent.intent)
                    .create().start().resume().get();

    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();

    assertNotNull(FormEntryActivity.mFormController);
}
项目:Fabric-Example-App-Android    文件:MraidNativeCommandHandlerTest.java   
@Test
public void isStorePictureAvailable_whenPermissionDeclaredAndMediaMounted_shouldReturnTrue() throws Exception {
    Robolectric.getShadowApplication().grantPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);

    assertThat(subject.isStorePictureSupported(context)).isTrue();
}
项目:Fabric-Example-App-Android    文件:MraidNativeCommandHandlerTest.java   
@Test
public void isStorePictureAvailable_whenPermissionDenied_shouldReturnFalse() throws Exception {
    Robolectric.getShadowApplication().denyPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);

    assertThat(subject.isStorePictureSupported(context)).isFalse();
}
项目:Fabric-Example-App-Android    文件:MraidNativeCommandHandlerTest.java   
@Test
public void isStorePictureAvailable_whenMediaUnmounted_shouldReturnFalse() throws Exception {
    Robolectric.getShadowApplication().grantPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_UNMOUNTED);

    assertThat(subject.isStorePictureSupported(context)).isFalse();
}
项目:Android-HttpDownloadManager    文件:DownloadManagerTest.java   
@Before public void setUp() throws Exception {
    ShadowLog.stream = System.out;
    mockWebServer = new MockWebServer();
    downloadManager = new DownloadManager.Builder().context(
        ShadowApplication.getInstance().getApplicationContext()).build();
    String filePath =
        ShadowEnvironment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
            + File.separator
            + "download.apk";

    request =
        new DownloadRequest.Builder().url(mockWebServer.url("/").toString())
            .destinationFilePath(filePath)
            .build();
}
项目:commcare-android    文件:FormRecordProcessingTest.java   
@Before
public void setup() {
    TestAppInstaller.installAppAndLogin(
            "jr://resource/commcare-apps/form_save_regressions/profile.ccpr",
            "test", "123");
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
}
项目:commcare-android    文件:FormIntentTests.java   
@Before
public void setup() {
    TestAppInstaller.installAppAndLogin(
            "jr://resource/commcare-apps/form_entry_tests/profile.ccpr",
            "test", "123");
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
}
项目:commcare-android    文件:IntentCalloutTests.java   
@Before
public void setup() {
    XFormAndroidInstaller.registerAndroidLevelFormParsers();
    TestAppInstaller.installAppAndLogin(
            "jr://resource/commcare-apps/phone_call/profile.ccpr",
            "test", "123");
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
}
项目:commcare-android    文件:CalendarLocaleTest.java   
@Before
public void setup() {
    TestAppInstaller.installAppAndLogin(
            "jr://resource/commcare-apps/calendar_tests/profile.ccpr",
            "test", "123");
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
}
项目:commcare-android    文件:EndOfFormTest.java   
@Before
public void setup() {
    TestAppInstaller.installAppAndLogin(
            "jr://resource/commcare-apps/form_nav_tests/profile.ccpr",
            "test", "123");
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
}
项目:open    文件:RouteFragmentTest.java   
private void loadTestGpxTrace() throws IOException {
    byte[] encoded = Files.readAllBytes(Paths.get("src/test/resources/lost.gpx"));
    String contents = new String(encoded, "UTF-8");

    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
    File directory = Environment.getExternalStorageDirectory();
    File file = new File(directory, "lost.gpx");
    FileWriter fileWriter = new FileWriter(file, false);
    fileWriter.write(contents);
    fileWriter.close();
}
项目:twitter-kit-android    文件:FileStoreImplTest.java   
@Test
public void testGetExternalCacheDir() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
    verifyFile(fileStore.getExternalCacheDir());
}
项目:twitter-kit-android    文件:FileStoreImplTest.java   
@Test
public void testGetExternalCacheDir_withoutExternalStorage() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_REMOVED);
    assertNull(fileStore.getExternalCacheDir());
}
项目:twitter-kit-android    文件:FileStoreImplTest.java   
@Test
public void testGetExternalFilesDir() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
    verifyFile(fileStore.getExternalFilesDir());
}
项目:twitter-kit-android    文件:FileStoreImplTest.java   
@Test
public void testGetExternalFilesDir_withoutExternalStorage() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_REMOVED);
    assertNull(fileStore.getExternalFilesDir());
}
项目:android-money-manager-ex    文件:MmexApplicationTests.java   
@After
public void tearDown() throws Exception {
    this.context = null;

    ShadowEnvironment.reset();
}