Java Code Examples for org.robolectric.shadows.ShadowEnvironment#setExternalStorageState()

The following examples show how to use org.robolectric.shadows.ShadowEnvironment#setExternalStorageState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RouteFragmentTest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example 2
Source File: FileStoreImplTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetExternalCacheDir() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
    verifyFile(fileStore.getExternalCacheDir());
}
 
Example 3
Source File: FileStoreImplTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetExternalCacheDir_withoutExternalStorage() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_REMOVED);
    assertNull(fileStore.getExternalCacheDir());
}
 
Example 4
Source File: FileStoreImplTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetExternalFilesDir() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
    verifyFile(fileStore.getExternalFilesDir());
}
 
Example 5
Source File: FileStoreImplTest.java    From twitter-kit-android with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetExternalFilesDir_withoutExternalStorage() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_REMOVED);
    assertNull(fileStore.getExternalFilesDir());
}
 
Example 6
Source File: XFormUpdateInfoTest.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
}
 
Example 7
Source File: CommCareTestRunner.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
@Override public void prepareTest(final Object test) {
    if (RuntimeEnvironment.application instanceof TestLifecycleApplication) {
        ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);
        super.prepareTest(test);
    }
}