org.robolectric.shadows.ShadowEnvironment Java Examples
The following examples show how to use
org.robolectric.shadows.ShadowEnvironment.
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: DownloadManagerTest.java From Android-HttpDownloadManager with Apache License 2.0 | 5 votes |
@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(); }
Example #2
Source File: RouteFragmentTest.java From open with GNU General Public License v3.0 | 5 votes |
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 #3
Source File: FileStoreImplTest.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Test public void testGetExternalCacheDir() { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED); verifyFile(fileStore.getExternalCacheDir()); }
Example #4
Source File: FileStoreImplTest.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Test public void testGetExternalCacheDir_withoutExternalStorage() { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_REMOVED); assertNull(fileStore.getExternalCacheDir()); }
Example #5
Source File: FileStoreImplTest.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Test public void testGetExternalFilesDir() { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED); verifyFile(fileStore.getExternalFilesDir()); }
Example #6
Source File: FileStoreImplTest.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Test public void testGetExternalFilesDir_withoutExternalStorage() { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_REMOVED); assertNull(fileStore.getExternalFilesDir()); }
Example #7
Source File: XFormUpdateInfoTest.java From commcare-android with Apache License 2.0 | 4 votes |
@Before public void setup() { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED); }
Example #8
Source File: CommCareTestRunner.java From commcare-android with Apache License 2.0 | 4 votes |
@Override public void prepareTest(final Object test) { if (RuntimeEnvironment.application instanceof TestLifecycleApplication) { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED); super.prepareTest(test); } }