ExternalStorageProviderTestpublic class ExternalStorageProviderTest extends android.test.AndroidTestCase
Fields Summary |
---|
private File | mTarget |
Methods Summary |
---|
private static void | assertNameEquals(java.lang.String expected, java.io.File actual)
assertEquals(expected, actual.getName());
| protected void | setUp()
super.setUp();
mTarget = getContext().getFilesDir();
FileUtils.deleteContents(mTarget);
| protected void | tearDown()
super.tearDown();
FileUtils.deleteContents(mTarget);
| public void | testBuildUniqueFile_dir()
assertNameEquals("test", buildUniqueFile(mTarget, Document.MIME_TYPE_DIR, "test"));
new File(mTarget, "test").mkdir();
assertNameEquals("test (1)", buildUniqueFile(mTarget, Document.MIME_TYPE_DIR, "test"));
assertNameEquals("test.jpg", buildUniqueFile(mTarget, Document.MIME_TYPE_DIR, "test.jpg"));
new File(mTarget, "test.jpg").mkdir();
assertNameEquals("test.jpg (1)", buildUniqueFile(mTarget, Document.MIME_TYPE_DIR, "test.jpg"));
| public void | testBuildUniqueFile_increment()
assertNameEquals("test.jpg", buildUniqueFile(mTarget, "image/jpeg", "test.jpg"));
new File(mTarget, "test.jpg").createNewFile();
assertNameEquals("test (1).jpg", buildUniqueFile(mTarget, "image/jpeg", "test.jpg"));
new File(mTarget, "test (1).jpg").createNewFile();
assertNameEquals("test (2).jpg", buildUniqueFile(mTarget, "image/jpeg", "test.jpg"));
| public void | testBuildUniqueFile_normal()
assertNameEquals("test.jpg", buildUniqueFile(mTarget, "image/jpeg", "test"));
assertNameEquals("test.jpg", buildUniqueFile(mTarget, "image/jpeg", "test.jpg"));
assertNameEquals("test.jpeg", buildUniqueFile(mTarget, "image/jpeg", "test.jpeg"));
assertNameEquals("TEst.JPeg", buildUniqueFile(mTarget, "image/jpeg", "TEst.JPeg"));
assertNameEquals("test.png.jpg", buildUniqueFile(mTarget, "image/jpeg", "test.png.jpg"));
assertNameEquals("test.png.jpg", buildUniqueFile(mTarget, "image/jpeg", "test.png"));
assertNameEquals("test.flac", buildUniqueFile(mTarget, "audio/flac", "test"));
assertNameEquals("test.flac", buildUniqueFile(mTarget, "audio/flac", "test.flac"));
assertNameEquals("test.flac", buildUniqueFile(mTarget, "application/x-flac", "test"));
assertNameEquals("test.flac", buildUniqueFile(mTarget, "application/x-flac", "test.flac"));
| public void | testBuildUniqueFile_unknown()
assertNameEquals("test", buildUniqueFile(mTarget, "application/octet-stream", "test"));
assertNameEquals("test.jpg", buildUniqueFile(mTarget, "application/octet-stream", "test.jpg"));
assertNameEquals(".test", buildUniqueFile(mTarget, "application/octet-stream", ".test"));
assertNameEquals("test", buildUniqueFile(mTarget, "lolz/lolz", "test"));
assertNameEquals("test.lolz", buildUniqueFile(mTarget, "lolz/lolz", "test.lolz"));
|
|