FileDocCategorySizeDatePackage
MediaPlayerApiTest.javaAPI DocAndroid 5.1 API15123Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest.functional.mediaplayback

MediaPlayerApiTest

public class MediaPlayerApiTest extends android.test.ActivityInstrumentationTestCase2
Junit / Instrumentation test case for the media player api

Fields Summary
private boolean
duratoinWithinTolerence
private String
TAG
private boolean
isWMAEnable
private boolean
isWMVEnable
android.content.Context
mContext
Constructors Summary
public MediaPlayerApiTest()


      
       super("com.android.mediaframeworktest", MediaFrameworkTest.class);
       isWMAEnable = MediaProfileReader.getWMAEnable();
       isWMVEnable = MediaProfileReader.getWMVEnable();
    
Methods Summary
protected voidsetUp()

       //Insert a 2 second before launching the test activity. This is
       //the workaround for the race condition of requesting the updated surface.
       Thread.sleep(2000);
       getActivity();
       super.setUp();
    
public voidtestAMRGetCurrentPosition()

      boolean currentPosition = CodecTest.getCurrentPosition(MediaNames.AMR);  
      assertTrue("AMR GetCurrentPosition", currentPosition);  
    
public voidtestAMRGetDuration()

      int duration = CodecTest.getDuration(MediaNames.AMR);  
      duratoinWithinTolerence = verifyDuration(duration, MediaNames.AMR_LENGTH);
      assertTrue("AMR getDuration", duratoinWithinTolerence);  
    
public voidtestAMRPause()

      boolean isPaused = CodecTest.pause(MediaNames.AMR);  
      assertTrue("AMR Pause", isPaused);  
    
public voidtestAMRSeekTo()

      boolean isLoop = CodecTest.seekTo(MediaNames.AMR);  
      assertTrue("AMR seekTo", isLoop);  
    
public voidtestAMRSeekToEnd()

      boolean isEnd = CodecTest.seekToEnd(MediaNames.AMR);  
      assertTrue("AMR seekToEnd", isEnd);  
    
public voidtestAMRSetLooping()

      boolean isLoop = CodecTest.setLooping(MediaNames.AMR);  
      assertTrue("AMR setLooping", isLoop);  
    
public voidtestGetThumbnail()

      boolean getThumbnail = CodecTest.getThumbnail(MediaNames.VIDEO_H264_AAC, MediaNames.GOLDEN_THUMBNAIL_OUTPUT);
      assertTrue("Get Thumbnail", getThumbnail);         
    
public voidtestIsLooping()

        boolean isLooping = CodecTest.isLooping(MediaNames.AMR);
        assertTrue("isLooping", isLooping);
    
public voidtestIsLoopingAfterReset()

        boolean isLooping = CodecTest.isLoopingAfterReset(MediaNames.AMR);
        assertTrue("isLooping after reset", isLooping);
    
public voidtestLargeVideoHeigth()

      int height = 0;
      height = CodecTest.videoHeight(MediaNames.VIDEO_LARGE_SIZE_3GP);
      Log.v(TAG, "Video height = " +  height);
      assertEquals("streaming video height", 240, height);           
    
public voidtestLargeVideoWidth()

      int width = 0;
      width = CodecTest.videoWidth(MediaNames.VIDEO_LARGE_SIZE_3GP);
      Log.v(TAG, "Video width = " +  width);
      assertEquals("streaming video width", 320, width);           
    
public voidtestLocalH263AMRPrepareAsyncCallback()

        boolean onPrepareSuccess =
            CodecTest.prepareAsyncCallback(MediaNames.VIDEO_H263_AMR, false);
        assertTrue("testLocalH263AMRPrepareAsyncCallback", onPrepareSuccess);
    
public voidtestLocalMp3PrepareAsyncCallback()

        boolean onPrepareSuccess = 
            CodecTest.prepareAsyncCallback(MediaNames.MP3CBR, false);
        assertTrue("LocalMp3prepareAsyncCallback", onPrepareSuccess);
    
public voidtestMIDIGetCurrentPosition()

      boolean currentPosition = CodecTest.getCurrentPosition(MediaNames.MIDI);  
      assertTrue("MIDI GetCurrentPosition", currentPosition);  
    
public voidtestMIDIGetDuration()

      int duration = CodecTest.getDuration(MediaNames.MIDI);  
      duratoinWithinTolerence = verifyDuration(duration, MediaNames.MIDI_LENGTH);
      assertTrue("MIDI getDuration", duratoinWithinTolerence);  
    
public voidtestMIDIPause()

      boolean isPaused = CodecTest.pause(MediaNames.MIDI);  
      assertTrue("MIDI Pause", isPaused);  
    
public voidtestMIDIPrepareStopRelease()

      CodecTest.prepareStopRelease(MediaNames.MIDI);  
      assertTrue("MIDI prepareStopRelease", true);  
    
public voidtestMIDISeekTo()

      boolean isLoop = CodecTest.seekTo(MediaNames.MIDI);  
      assertTrue("MIDI seekTo", isLoop);  
    
public voidtestMIDISeekToEnd()

      boolean isEnd = CodecTest.seekToEnd(MediaNames.MIDI);  
      assertTrue("MIDI seekToEnd", isEnd);  
    
public voidtestMIDISetLooping()

      boolean isLoop = CodecTest.setLooping(MediaNames.MIDI);  
      assertTrue("MIDI setLooping", isLoop);  
    
public voidtestMP3CBRGetCurrentPosition()

      boolean currentPosition = CodecTest.getCurrentPosition(MediaNames.MP3CBR);       
      assertTrue("MP3CBR GetCurrentPosition", currentPosition);  
    
public voidtestMP3CBRGetDuration()

      int duration = CodecTest.getDuration(MediaNames.MP3CBR);
      duratoinWithinTolerence = verifyDuration(duration, MediaNames.MP3CBR_LENGTH);
      assertTrue("MP3CBR getDuration", duratoinWithinTolerence);  
    
public voidtestMP3CBRPause()

      boolean isPaused = CodecTest.pause(MediaNames.MP3CBR);       
      assertTrue("MP3CBR Pause", isPaused);  
    
public voidtestMP3CBRPrepareStopRelease()

      CodecTest.prepareStopRelease(MediaNames.MP3CBR);       
      assertTrue("MP3CBR prepareStopRelease", true);  
    
public voidtestMP3CBRSeekBeforeStart()

      boolean seekBeforePlay = CodecTest.seektoBeforeStart(MediaNames.MP3CBR);       
      assertTrue("MP3CBR SeekBeforePlay", seekBeforePlay);  
    
public voidtestMP3CBRSeekTo()

      boolean isLoop = CodecTest.seekTo(MediaNames.MP3CBR);     
      assertTrue("MP3CBR seekTo", isLoop);  
    
public voidtestMP3CBRSeekToEnd()

      boolean isEnd = CodecTest.seekToEnd(MediaNames.MP3CBR);     
      assertTrue("MP3CBR seekToEnd", isEnd);  
    
public voidtestMP3CBRSetLooping()

      boolean isLoop = CodecTest.setLooping(MediaNames.MP3CBR);     
      assertTrue("MP3CBR setLooping", isLoop);  
    
public voidtestMP3VBRGetCurrentPosition()

      boolean currentPosition = CodecTest.getCurrentPosition(MediaNames.MP3VBR);  
      assertTrue("MP3VBR GetCurrentPosition", currentPosition);  
    
public voidtestMP3VBRGetDuration()

      int duration = CodecTest.getDuration(MediaNames.MP3VBR);
      Log.v(TAG, "getDuration");
      duratoinWithinTolerence = verifyDuration(duration, MediaNames.MP3VBR_LENGTH);
      assertTrue("MP3VBR getDuration", duratoinWithinTolerence);  
    
public voidtestMP3VBRPause()

      boolean isPaused = CodecTest.pause(MediaNames.MP3VBR);  
      assertTrue("MP3VBR Pause", isPaused);  
    
public voidtestMP3VBRSeekTo()

      boolean isLoop = CodecTest.seekTo(MediaNames.MP3VBR);
      Log.v(TAG, "seekTo");
      assertTrue("MP3VBR seekTo", isLoop);  
    
public voidtestMP3VBRSeekToEnd()

      boolean isEnd = CodecTest.seekToEnd(MediaNames.MP3VBR);
      Log.v(TAG, "seekTo");
      assertTrue("MP3VBR seekToEnd", isEnd);  
    
public voidtestMP3VBRSetLooping()

      boolean isLoop = CodecTest.setLooping(MediaNames.MP3VBR);
      Log.v(TAG, "setLooping");
      assertTrue("MP3VBR setLooping", isLoop);  
    
public voidtestMidiResources()

      boolean midiResources = CodecTest.resourcesPlayback(MediaFrameworkTest.midiafd,16000);
      assertTrue("Play midi from resources", midiResources);         
    
public voidtestMp3Resources()

      boolean mp3Resources = CodecTest.resourcesPlayback(MediaFrameworkTest.mp3afd,25000);
      assertTrue("Play mp3 from resources", mp3Resources);         
    
public voidtestPrepareAsyncReset()

      //assertTrue(MediaFrameworkTest.checkStreamingServer());
      boolean isReset = CodecTest.prepareAsyncReset(MediaNames.STREAM_MP3);
      assertTrue("PrepareAsync Reset", isReset);         
    
public voidtestSoundRecord()

      boolean isRecordered = CodecTest.mediaRecorderRecord(MediaNames.RECORDER_OUTPUT);
      assertTrue("Recorder", isRecordered);         
    
public voidtestStreamPrepareAsyncCallback()

        //assertTrue(MediaFrameworkTest.checkStreamingServer());
        boolean onPrepareSuccess = 
            CodecTest.prepareAsyncCallback(MediaNames.STREAM_H264_480_360_1411k, false);
        assertTrue("StreamH264PrepareAsyncCallback", onPrepareSuccess);
    
public voidtestStreamPrepareAsyncCallbackReset()

        //assertTrue(MediaFrameworkTest.checkStreamingServer());
        boolean onPrepareSuccess = 
            CodecTest.prepareAsyncCallback(MediaNames.STREAM_H264_480_360_1411k, true);
        assertTrue("StreamH264PrepareAsyncCallback", onPrepareSuccess);
    
public voidtestVideoH263AACSeekTo()

      boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_H263_AAC);
      assertTrue("H263AAC SeekTo", isSeek);         
    
public voidtestVideoH263AMRSeekTo()

      boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_H263_AMR);
      assertTrue("H263AMR SeekTo", isSeek);         
    
public voidtestVideoH264AACSeekTo()

      boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_H264_AAC);
      assertTrue("H264AAC SeekTo", isSeek);         
    
public voidtestVideoH264AMRSeekTo()

      boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_H264_AMR);
      assertTrue("H264AMR SeekTo", isSeek);         
    
public voidtestVideoMP4SeekTo()

      boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_MP4);
      assertTrue("Local MP4 SeekTo", isSeek);          
    
public voidtestVideoWebmSeekTo()

      boolean isSeek = CodecTest.videoSeekTo(MediaNames.VIDEO_WEBM);
      assertTrue("WEBM SeekTo", isSeek);
    
public voidtestWAVSeekToEnd()

        boolean isEnd = CodecTest.seekToEnd(MediaNames.WAV);
        assertTrue("WAV seekToEnd", isEnd);
    
public booleanverifyDuration(int duration, int expectedDuration)

      if ((duration > expectedDuration * 1.1) || (duration < expectedDuration * 0.9))
         return false;
      else
        return true;