FileDocCategorySizeDatePackage
MediaMimeTest.javaAPI DocAndroid 1.5 API5247Wed May 06 22:42:00 BST 2009com.android.mediaframeworktest.functional

MediaMimeTest

public class MediaMimeTest extends android.test.ActivityInstrumentationTestCase2

Fields Summary
private final String
TAG
private android.content.Context
mContext
private final String
MP3_FILE
private final String
MEDIA_PLAYBACK_NAME
Constructors Summary
public MediaMimeTest()


      
        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
    
Methods Summary
private voidassertMediaPlaybackActivityHandles(java.lang.String mime)

        ResolveInfo ri = resolveMime(mime);

        assertNotNull(ri);
        assertEquals(MEDIA_PLAYBACK_NAME, ri.activityInfo.name.toString());
    
private voidassertNoActivityHandles(java.lang.String mime)

        assertNull(resolveMime(mime));
    
private android.content.pm.ResolveInforesolveMime(java.lang.String mime)

        Intent viewIntent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.fromParts("file", MP3_FILE, null);

        viewIntent.setDataAndType(uri, mime);
        return mContext.getPackageManager().resolveActivity(
                viewIntent, PackageManager.MATCH_DEFAULT_ONLY);
    
protected voidsetUp()

      super.setUp();
      mContext = getActivity();
      // Checks you have all the test files on your SDCARD.
      assertTrue(new File(MP3_FILE).exists());
    
protected voidtearDown()

     
        super.tearDown();              
    
public voidtestCheckActivityResolverMimeHandlingIsCaseSensitive()

        assertNoActivityHandles("AUDIO/MP3");   // <--- look uppercase
    
public voidtestCheckMediaPlaybackHandlesApplicationItunes()

        assertMediaPlaybackActivityHandles("application/itunes");
    
public voidtestCheckMediaPlaybackHandlesAudio()

        assertMediaPlaybackActivityHandles("audio/*");
    
public voidtestCheckMediaPlaybackHandlesAudioMp3()

        assertMediaPlaybackActivityHandles("audio/mp3");
    
public voidtestCheckWhiteSpacesInMimeTypeHandling()

        assertNoActivityHandles(" audio/mp3");
        assertNoActivityHandles(" audio/mp3 ");
        assertMediaPlaybackActivityHandles("audio/mp3 ");