FileDocCategorySizeDatePackage
RootsCacheTest.javaAPI DocAndroid 5.1 API4761Thu Mar 12 22:22:40 GMT 2015com.android.documentsui

RootsCacheTest

public class RootsCacheTest extends android.test.AndroidTestCase

Fields Summary
private com.android.documentsui.model.RootInfo
mNull
private com.android.documentsui.model.RootInfo
mEmpty
private com.android.documentsui.model.RootInfo
mWild
private com.android.documentsui.model.RootInfo
mImages
private com.android.documentsui.model.RootInfo
mAudio
private com.android.documentsui.model.RootInfo
mDocs
private com.android.documentsui.model.RootInfo
mMalformed1
private com.android.documentsui.model.RootInfo
mMalformed2
private List
mRoots
private com.android.documentsui.DocumentsActivity.State
mState
Constructors Summary
Methods Summary
private static voidassertContainsExactly(java.util.List expected, java.util.List actual)

        assertEquals(expected.size(), actual.size());
        for (Object o : expected) {
            assertTrue(actual.contains(o));
        }
    
private static com.android.documentsui.model.RootInfobuildForMimeTypes(java.lang.String mimeTypes)

        final RootInfo root = new RootInfo();
        root.derivedMimeTypes = mimeTypes;
        return root;
    
protected voidsetUp()


    
         
        super.setUp();

        mState = new State();
        mState.action = State.ACTION_OPEN;
        mState.showAdvanced = true;
        mState.localOnly = false;
    
public voidtestMatchingRootsApplication()

        mState.acceptMimes = new String[] { "application/*" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mAudio, mDocs),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsAudioSpecific()

        mState.acceptMimes = new String[] { "audio/mpeg" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mAudio),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsAudioWild()

        mState.acceptMimes = new String[] { "audio/*" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mAudio),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsAudioWildOrImageWild()

        mState.acceptMimes = new String[] { "audio/*", "image/*" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mAudio, mImages),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsDocument()

        mState.acceptMimes = new String[] { "application/msword" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mDocs),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsEverything()

        mState.acceptMimes = new String[] { "*/*" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsFlacOrPng()

        mState.acceptMimes = new String[] { "application/x-flac", "image/png" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mAudio, mImages),
                RootsCache.getMatchingRoots(mRoots, mState));
    
public voidtestMatchingRootsPngOrWild()

        mState.acceptMimes = new String[] { "image/png", "*/*" };
        assertContainsExactly(
                Lists.newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2),
                RootsCache.getMatchingRoots(mRoots, mState));