MemoryFileProviderTestpublic class MemoryFileProviderTest extends android.test.AndroidTestCase Tests reading a MemoryFile-based AssestFile from a ContentProvider running
in a different process. |
Methods Summary |
---|
public void | testClose()
ContentResolver resolver = getContext().getContentResolver();
// open enough file descriptors that we will crash something if we leak FDs
// or address space
for (int i = 0; i < 1025; i++) {
Uri uri = Uri.parse("content://android.content.MemoryFileProvider/huge");
InputStream in = resolver.openInputStream(uri);
assertNotNull("Failed to open stream number " + i, in);
byte[] buf = new byte[MemoryFileProvider.TEST_BLOB.length];
int count = in.read(buf);
assertEquals(buf.length, count);
assertTrue(Arrays.equals(MemoryFileProvider.TEST_BLOB, buf));
in.close();
}
| public void | testFile()
ContentResolver resolver = getContext().getContentResolver();
Uri uri = Uri.parse("content://android.content.MemoryFileProvider/file");
byte[] buf = new byte[MemoryFileProvider.TEST_BLOB.length];
InputStream in = resolver.openInputStream(uri);
assertNotNull(in);
int count = in.read(buf);
assertEquals(buf.length, count);
assertEquals(-1, in.read());
in.close();
assertTrue(Arrays.equals(MemoryFileProvider.TEST_BLOB, buf));
| public void | testRead()
ContentResolver resolver = getContext().getContentResolver();
Uri uri = Uri.parse("content://android.content.MemoryFileProvider/data/1/blob");
byte[] buf = new byte[MemoryFileProvider.TEST_BLOB.length];
InputStream in = resolver.openInputStream(uri);
assertNotNull(in);
int count = in.read(buf);
assertEquals(buf.length, count);
assertEquals(-1, in.read());
in.close();
assertTrue(Arrays.equals(MemoryFileProvider.TEST_BLOB, buf));
|
|