FileDocCategorySizeDatePackage
ExternalStorageProviderTest.javaAPI DocAndroid 5.1 API4054Thu Mar 12 22:22:40 GMT 2015com.android.externalstorage

ExternalStorageProviderTest

public class ExternalStorageProviderTest extends android.test.AndroidTestCase

Fields Summary
private File
mTarget
Constructors Summary
Methods Summary
private static voidassertNameEquals(java.lang.String expected, java.io.File actual)

        assertEquals(expected, actual.getName());
    
protected voidsetUp()

        super.setUp();
        mTarget = getContext().getFilesDir();
        FileUtils.deleteContents(mTarget);
    
protected voidtearDown()

        super.tearDown();
        FileUtils.deleteContents(mTarget);
    
public voidtestBuildUniqueFile_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 voidtestBuildUniqueFile_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 voidtestBuildUniqueFile_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 voidtestBuildUniqueFile_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"));