Search in sources :

Example 61 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class MediaAudioEffectTest method test1_6AuxiliaryOnMediaPlayerFailure.

//Test case 1.6: test auxiliary effect attachement failure before setDatasource
@LargeTest
public void test1_6AuxiliaryOnMediaPlayerFailure() throws Exception {
    boolean result = false;
    String msg = "test1_6AuxiliaryOnMediaPlayerFailure()";
    try {
        createMediaPlayerLooper();
        synchronized (lock) {
            try {
                lock.wait(1000);
            } catch (Exception e) {
                Log.e(TAG, "Looper creation: wait was interrupted.");
            }
        }
        // mMediaPlayer has been initialized?
        assertTrue(mInitialized);
        mError = 0;
        AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
        assertNotNull(msg + ": could not create AudioEffect", effect);
        synchronized (lock) {
            try {
                mMediaPlayer.attachAuxEffect(effect.getId());
                lock.wait(1000);
            } catch (Exception e) {
                Log.e(TAG, "Attach effect: wait was interrupted.");
            }
        }
        assertTrue(msg + ": no error on attachAuxEffect", mError != 0);
        result = true;
        effect.release();
        terminateMediaPlayerLooper();
    } catch (IllegalArgumentException e) {
        msg = msg.concat(": Equalizer not found");
        loge(msg, ": Equalizer not found");
    } catch (UnsupportedOperationException e) {
        msg = msg.concat(": Effect library not loaded");
        loge(msg, ": Effect library not loaded");
    } catch (Exception e) {
        loge(msg, "Could not create media player:" + e);
    }
    assertTrue(msg, result);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 62 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class MediaAudioEffectTest method test3_4SetParameterIntArrayIntArray.

//Test case 3.4: test setParameter(int[], int[])
@LargeTest
public void test3_4SetParameterIntArrayIntArray() throws Exception {
    boolean result = false;
    String msg = "test3_4SetParameterIntArrayIntArray()";
    AudioEffect effect = null;
    try {
        effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
        assertNotNull(msg + ": could not create AudioEffect", effect);
        int[] param = new int[1];
        int[] value = new int[1];
        param[0] = EnvironmentalReverb.PARAM_DECAY_TIME;
        value[0] = 0;
        if (effect.setParameter(param, value) == AudioEffect.SUCCESS) {
            result = true;
        }
    } catch (IllegalArgumentException e) {
        msg = msg.concat(": Bad parameter value");
        loge(msg, "Bad parameter value");
    } catch (UnsupportedOperationException e) {
        msg = msg.concat(": setParameter() rejected");
        loge(msg, "setParameter() rejected");
    } catch (IllegalStateException e) {
        msg = msg.concat("setParameter() called in wrong state");
        loge(msg, "setParameter() called in wrong state");
    } finally {
        if (effect != null) {
            effect.release();
        }
    }
    assertTrue(msg, result);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 63 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testFrameOverlayImageItem.

/**
     * To test Frame Overlay for Media Image Item
     */
@LargeTest
public void testFrameOverlayImageItem() throws Exception {
    final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
    final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
    final String overlayFile2 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png";
    final MediaImageItem mediaImageItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", imageItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem1);
    final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, 480);
    final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", mBitmap, 5000, 5000);
    mediaImageItem1.addOverlay(overlayFrame1);
    assertEquals("Overlay : Media Item", mediaImageItem1, overlayFrame1.getMediaItem());
    assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1"));
    assertEquals("Overlay Bitmap", mBitmap, overlayFrame1.getBitmap());
    assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime());
    assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration());
    Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 640, 480);
    overlayFrame1.setBitmap(upddateBmp);
    assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap());
    upddateBmp.recycle();
}
Also used : Bitmap(android.graphics.Bitmap) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayFrame(android.media.videoeditor.OverlayFrame) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 64 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testEffectSetgetDuration.

/**
     * To test Effect Color : Set duration and Get Duration
     */
@LargeTest
public void testEffectSetgetDuration() throws Exception {
    final String videoItemFileName = INPUT_FILE_PATH + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4";
    final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, videoItemRenderingMode);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 1000, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
    mediaVideoItem1.addEffect(effectColor1);
    effectColor1.setDuration(5000);
    assertEquals("Updated Effect Duration", 5000, effectColor1.getDuration());
    try {
        effectColor1.setDuration(mediaVideoItem1.getDuration() + 1000);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect Color duration > mediaVideoItemDuration", flagForException);
    assertEquals("Effect Duration", 5000, effectColor1.getDuration());
    flagForException = false;
    try {
        effectColor1.setDuration(-1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Effect Color duration = -1", flagForException);
}
Also used : EffectColor(android.media.videoeditor.EffectColor) MediaVideoItem(android.media.videoeditor.MediaVideoItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 65 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorAPITest method testTransitionFadeBlack.

/**
     * To test Transition : Fade To Black with all behavior
     * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
     */
@LargeTest
public void testTransitionFadeBlack() throws Exception {
    final String videoItemFilename1 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final String videoItemFilename2 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_128kbps_1_35.3gp";
    final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String videoItemFilename3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_192kbps_1_5.mp4";
    final String videoItemFilename4 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
    final String videoItemFilename5 = INPUT_FILE_PATH + "H263_profile0_176x144_10fps_96kbps_0_25.3gp";
    boolean flagForException = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(0, 15000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem2.setExtractBoundaries(0, 15000);
    mVideoEditor.addMediaItem(mediaVideoItem2);
    final TransitionFadeBlack transition1And2 = mVideoEditorHelper.createTFadeBlack("transition1And2", mediaVideoItem1, mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP);
    mVideoEditor.addTransition(transition1And2);
    assertTrue("Transition ID", transition1And2.getId().equals("transition1And2"));
    assertEquals("Transtion After Media item", mediaVideoItem1, transition1And2.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem2, transition1And2.getBeforeMediaItem());
    assertEquals("Transtion Duration", 3000, transition1And2.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, transition1And2.getBehavior());
    final MediaImageItem mediaImageItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaImageItem3);
    final TransitionFadeBlack transition2And3 = mVideoEditorHelper.createTFadeBlack("transition2And3", mediaVideoItem2, mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN);
    mVideoEditor.addTransition(transition2And3);
    assertTrue("Transition ID", transition2And3.getId().equals("transition2And3"));
    assertEquals("Transtion After Media item", mediaVideoItem2, transition2And3.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaImageItem3, transition2And3.getBeforeMediaItem());
    assertEquals("Transtion Duration", 1000, transition2And3.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, transition2And3.getBehavior());
    final MediaVideoItem mediaVideoItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem4.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaVideoItem4);
    final TransitionFadeBlack transition3And4 = mVideoEditorHelper.createTFadeBlack("transition3And4", mediaImageItem3, mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR);
    mVideoEditor.addTransition(transition3And4);
    assertTrue("Transition ID", transition3And4.getId().equals("transition3And4"));
    assertEquals("Transtion After Media item", mediaImageItem3, transition3And4.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem4, transition3And4.getBeforeMediaItem());
    assertEquals("Transtion Duration", 5000, transition3And4.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, transition3And4.getBehavior());
    final MediaVideoItem mediaVideoItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mVideoEditor.addMediaItem(mediaVideoItem5);
    final TransitionFadeBlack transition4And5 = mVideoEditorHelper.createTFadeBlack("transition4And5", mediaVideoItem4, mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST);
    mVideoEditor.addTransition(transition4And5);
    assertTrue("Transition ID", transition4And5.getId().equals("transition4And5"));
    assertEquals("Transtion After Media item", mediaVideoItem4, transition4And5.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem5, transition4And5.getBeforeMediaItem());
    assertEquals("Transtion Duration", 8000, transition4And5.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, transition4And5.getBehavior());
    final MediaVideoItem mediaVideoItem6 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem6.setExtractBoundaries(0, 20000);
    mVideoEditor.addMediaItem(mediaVideoItem6);
    final TransitionFadeBlack transition5And6 = mVideoEditorHelper.createTFadeBlack("transition5And6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW);
    mVideoEditor.addTransition(transition5And6);
    assertTrue("Transition ID", transition5And6.getId().equals("transition5And6"));
    assertEquals("Transtion After Media item", mediaVideoItem5, transition5And6.getAfterMediaItem());
    assertEquals("Transtion Before Media item", mediaVideoItem6, transition5And6.getBeforeMediaItem());
    assertEquals("Transtion Duration", 2000, transition5And6.getDuration());
    assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, transition5And6.getBehavior());
    flagForException = false;
    try {
        mVideoEditorHelper.createTFadeBlack("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
    flagForException = false;
    try {
        mVideoEditorHelper.createTFadeBlack("transitiond6", mediaVideoItem5, mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1);
    } catch (IllegalArgumentException e) {
        flagForException = true;
    }
    assertTrue("Transition FadeBlack with Invalid behavior", flagForException);
}
Also used : TransitionFadeBlack(android.media.videoeditor.TransitionFadeBlack) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaImageItem(android.media.videoeditor.MediaImageItem) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

LargeTest (android.test.suitebuilder.annotation.LargeTest)1579 AudioEffect (android.media.audiofx.AudioEffect)234 AudioTrack (android.media.AudioTrack)222 View (android.view.View)147 File (java.io.File)144 MediaVideoItem (android.media.videoeditor.MediaVideoItem)115 Uri (android.net.Uri)99 ListView (android.widget.ListView)72 Cursor (android.database.Cursor)69 Bitmap (android.graphics.Bitmap)62 Instrumentation (android.app.Instrumentation)61 MediaPlayer (android.media.MediaPlayer)60 WifiConfiguration (android.net.wifi.WifiConfiguration)53 SurfaceHolder (android.view.SurfaceHolder)50 MediaImageItem (android.media.videoeditor.MediaImageItem)49 IOException (java.io.IOException)48 AudioManager (android.media.AudioManager)42 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)42 VpnProfile (com.android.internal.net.VpnProfile)42 Request (android.app.DownloadManager.Request)41