diff options
author | Basavapatna Dattaguru <dattaguru@google.com> | 2011-02-10 21:52:56 -0800 |
---|---|---|
committer | Basavapatna Dattaguru <dattaguru@google.com> | 2011-02-11 13:30:07 -0800 |
commit | 86e9e9be1e6cbcc0f8dbb2ecc41fafa7ddb5f8d1 (patch) | |
tree | 50edf50d51a2235a301a9e018cf6851b0ddbb520 /media/tests | |
parent | ba441101179d1d4805c15dd63b917b145b98ee7d (diff) | |
download | frameworks_base-86e9e9be1e6cbcc0f8dbb2ecc41fafa7ddb5f8d1.zip frameworks_base-86e9e9be1e6cbcc0f8dbb2ecc41fafa7ddb5f8d1.tar.gz frameworks_base-86e9e9be1e6cbcc0f8dbb2ecc41fafa7ddb5f8d1.tar.bz2 |
Video Editor CTS Test Code: annotation suppress
Fix for Issue: ID:3396697
Updated with review comments
Change-Id: Ie20e60598f046b23ed49b2533e9d500607a23c17
Diffstat (limited to 'media/tests')
3 files changed, 3288 insertions, 1 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java index 46135ff..1862fd5 100755 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,9 @@ import com.android.mediaframeworktest.functional.MediaEqualizerTest; import com.android.mediaframeworktest.functional.MediaPresetReverbTest; import com.android.mediaframeworktest.functional.MediaVirtualizerTest; import com.android.mediaframeworktest.functional.MediaVisualizerTest; +/*import for VideoEditor Test cases*/ +import com.android.mediaframeworktest.functional.VideoEditorAPITest; + import junit.framework.TestSuite; import android.test.InstrumentationTestRunner; @@ -69,6 +72,8 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner { suite.addTestSuite(MediaPresetReverbTest.class); suite.addTestSuite(MediaVirtualizerTest.class); suite.addTestSuite(MediaVisualizerTest.class); + /*Test for Video Editor*/ + suite.addTestSuite(VideoEditorAPITest.class); return suite; } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/VideoEditorHelper.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/VideoEditorHelper.java new file mode 100644 index 0000000..dd7c4c6 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/VideoEditorHelper.java @@ -0,0 +1,479 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mediaframeworktest; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; + +import junit.framework.Assert; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.media.videoeditor.AudioTrack; +import android.media.videoeditor.EffectColor; +import android.media.videoeditor.MediaImageItem; +import android.media.videoeditor.MediaItem; +import android.media.videoeditor.MediaVideoItem; +import android.media.videoeditor.OverlayFrame; +import android.media.videoeditor.TransitionAlpha; +import android.media.videoeditor.TransitionCrossfade; +import android.media.videoeditor.TransitionFadeBlack; +import android.media.videoeditor.TransitionSliding; +import android.media.videoeditor.VideoEditor; +import android.media.videoeditor.VideoEditorFactory; +import android.util.Log; +import android.os.Environment; + +/** + * This class has the names of the all the activity name and variables in the + * instrumentation test. + */ +public class VideoEditorHelper extends Assert { + + private final String TAG = "VideoEditorMediaNames"; + + public VideoEditorHelper() { + + } + + public static final String PROJECT_LOCATION_COMMON = + Environment.getExternalStorageDirectory().toString() + "/"; + + public static final String INPUT_FILE_PATH_COMMON = PROJECT_LOCATION_COMMON + + "media_api/videoeditor/"; + + // ----------------------------------------------------------------- + // HELPER METHODS + // ----------------------------------------------------------------- + + /** + * This method creates an object of VideoEditor + * + * @param projectPath the directory where all files related to project will + * be stored + * @param className The class which implements the VideoEditor Class + * @return the object of VideoEditor + */ + public VideoEditor createVideoEditor(String projectPath) { + VideoEditor mVideoEditor = null; + try { + mVideoEditor = VideoEditorFactory.create(projectPath); + assertNotNull("VideoEditor", mVideoEditor); + } catch (Exception e) { + fail("Unable to create Video Editor"); + } + return mVideoEditor; + } + + /** + *This method deletes the VideoEditor object created using + * createVideoEditor method + * + * @param videoEditor the VideoEditor object which needs to be cleaned up + */ + public void destroyVideoEditor(VideoEditor videoEditor) { + // Release VideoEditor + if (videoEditor != null) { + try { + videoEditor.release(); + } catch (Exception e) { + fail("Unable to destory Video Editor"); + } + } + } + + /** + *This Method checks the Range in "RangePercent" (say 10) + * + * @param int Expected data + * @param actual data + * @return boolean flag which confirms the range matching + */ + public boolean checkRange(long expected, long actual, long rangePercent) { + long range = 0; + range = (100 * actual) / expected; + + Log.i("checkRange", "Range = " + range); + if ((range > (100 - rangePercent)) && (range < (100 + rangePercent))) { + return true; + } else { + return false; + } + } + + /** + *This Method Creates a Bitmap with the given input file + * + * @param file the Input whose Bitmap has top be extracted + * @return an Object of EffectColor + */ + public Bitmap getBitmap(String file, int width, int height) throws IOException { + assertNotNull("Bitmap File is Null", file); + FileInputStream inputStream = null; + Bitmap overlayBmp = null; + if (!new File(file).exists()) + throw new IOException("File not Found " + file); + try { + final BitmapFactory.Options dbo = new BitmapFactory.Options(); + dbo.inJustDecodeBounds = true; + dbo.outWidth = width; + dbo.outHeight = height; + File flPtr = new File(file); + inputStream = new FileInputStream(flPtr); + final Bitmap srcBitmap = BitmapFactory.decodeStream(inputStream); + overlayBmp = Bitmap.createBitmap(srcBitmap); + assertNotNull("Bitmap 1", srcBitmap); + assertNotNull("Bitmap 2", overlayBmp); + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return overlayBmp; + } + + /** + *This Method Create a Media Video Item with the specified params + * + * @return an Object of MediaVideoItem + */ + public MediaVideoItem createMediaItem(VideoEditor videoEditor, + String MediaId, String filename, int renderingMode) { + MediaVideoItem mvi = null; + try { + mvi = new MediaVideoItem(videoEditor, MediaId, filename, + renderingMode); + assertNotNull("Can not create an object of MediaVideoItem", mvi); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException + ("Can not create an object of Media Video Item with file name = " + + filename + " Issue = " + e.toString()); + } catch (IOException e) { + assertTrue + ("Can not create an object of Media Video Item with file name = " + + filename + " Issue = " + e.toString(), false); + } + return mvi; + } + + /** + *This Method Create a Media Image Item with the specified params + * + * @return an Object of MediaImageItem + */ + public MediaImageItem createMediaItem(VideoEditor videoEditor, + String MediaId, String filename, long duration, int renderingMode) { + MediaImageItem mii = null; + try { + mii = new MediaImageItem(videoEditor, MediaId, filename, duration, + renderingMode); + assertNotNull("Can not create an object of MediaImageItem", mii); + + } catch (IllegalArgumentException e) { + assertTrue("Can not create an object of Media Image with file name = " + + filename + " Issue = " + e.toString(), false); + } catch (IOException e) { + assertTrue("Can not create an object of Media Image with file name = " + + filename + " Issue = " + e.toString(), false); + } + return mii; + } + + /** + *This Method Create a Effect with the specified params + * + * @return an Object of EffectColor + */ + public EffectColor createEffectItem(MediaItem mediaItem, String effectId, + long startTime, long duration, int effectType, int colorType) { + EffectColor effectonMVI = null; + effectonMVI = new EffectColor(mediaItem, effectId, startTime, + duration, effectType, colorType); + return effectonMVI; + } + + /** + *This Method creates object of Type Transition Cross fade + * + * @return TransitionCrossfade object + */ + public TransitionCrossfade createTCrossFade(String transitionId, + MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, + int behavior) { + Log.i("TransitionCrossfade Details === ", "Transid ID = " + transitionId + + " Duration= " + durationMs + " Behaviour " + behavior); + + TransitionCrossfade transitionCF = null; + transitionCF = new TransitionCrossfade(transitionId, afterMediaItem, + beforeMediaItem, durationMs, behavior); + return transitionCF; + } + + /** + *This Method creates object of Type TransitionFadeBlack + * + * @return TransitionFadeBlack object + */ + public TransitionFadeBlack createTFadeBlack(String transitionId, + MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, + int behavior) { + TransitionFadeBlack transitionFB = null; + + transitionFB = new TransitionFadeBlack(transitionId, afterMediaItem, + beforeMediaItem, durationMs, behavior); + return transitionFB; + } + + /** + *This Method creates object of Type TransitionSliding + * + * @return TransitionSliding object + */ + public TransitionSliding createTSliding(String transitionId, + MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, + int behavior, int direction) { + TransitionSliding transSlide = null; + transSlide = new TransitionSliding(transitionId, afterMediaItem, + beforeMediaItem, durationMs, behavior, direction); + return transSlide; + } + + /** + *This Method creates object of Type TranistionAlpha + * + * @return TranistionAlpha object + */ + + public TransitionAlpha createTAlpha(String transitionId, + MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, + int behavior, String maskFilename, int blendingPercent, boolean invert) { + TransitionAlpha transA = null; + transA = new TransitionAlpha(transitionId, afterMediaItem, + beforeMediaItem, durationMs, behavior, maskFilename, + blendingPercent, invert); + return transA; + } + + /** + *This Method creates object of Type OverlayFrame + * + * @return OverlayFrame object + */ + + public OverlayFrame createOverlay(MediaItem mediaItem, String overlayId, + Bitmap bitmap, long startTimeMs, long durationMs) { + OverlayFrame overLayFrame = null; + overLayFrame = new OverlayFrame(mediaItem, overlayId, bitmap, + startTimeMs, durationMs); + return overLayFrame; + } + + /** + *This Method creates object of Type AudioTrack + * + * @return OverlayFrame object + */ + public AudioTrack createAudio(VideoEditor videoEditor, String audioTrackId, + String filename) { + AudioTrack audio = null; + try { + audio = new AudioTrack(videoEditor, audioTrackId, filename); + assertNotNull("Cant not create an object of an AudioTrack " + + audioTrackId, audio); + } catch (IllegalArgumentException e) { + assertTrue("Can not create object of an AudioTrack " + + audioTrackId + " Issue = " + e.toString(), false); + } catch (IOException e) { + assertTrue("Can not create object of an AudioTrack " + + audioTrackId + " Issue = " + e.toString(), false); + } + return audio; + } + + /** + *This Method validates the Exported Movie,as per the specified params + * during Export + */ + + public void validateExport(VideoEditor videoEditor, String fileName, + int export_height, int startTime, long endTime, int vCodec, int aCodec) { + File tempFile = new File(fileName); + assertEquals("Exported FileName", tempFile.exists(), true); + final MediaVideoItem mvi = createMediaItem(videoEditor, "m1", fileName, + MediaItem.RENDERING_MODE_BLACK_BORDER); + + Log.i(TAG, "VideoCodec for file = " + fileName + + "\tExpected Video Codec = " + vCodec + "\tActual Video Codec = " + + mvi.getVideoType()); + assertEquals("Export: Video Codec Mismatch for file = " + fileName + + "\t<expected> " + vCodec + "\t<actual> " + mvi.getVideoType(), + vCodec, mvi.getVideoType()); + + Log.i(TAG, "Height for file = " + fileName + "\tExpected Height = " + + export_height + "\tActual VideoHeight = " + mvi.getHeight()); + assertEquals("Export height Mismatch for file " + fileName + + "\t<expected> " + export_height + "\t<actual> " + mvi.getHeight(), + export_height, mvi.getHeight()); + if (startTime == 0) { + if (endTime != 0) { + Log.i(TAG, "TimeLine Expected = " + (startTime + endTime) + + "\t VideoTime= " + mvi.getTimelineDuration()); + assertTrue("Timeline Duration Mismatch for file " + fileName + + "<expected> " + (startTime + endTime) + "\t<actual> " + + mvi.getTimelineDuration(), checkRange((startTime + + endTime), mvi.getTimelineDuration(), 10)); + } + } else { + Log.i(TAG, "TimeLine Expected = " + (endTime - startTime) + + "\t VideoTime= " + mvi.getTimelineDuration()); + assertTrue("Timeline Duration Mismatch for file " + fileName + + "<expected> " + (endTime - startTime) + "\t<actual> " + + mvi.getTimelineDuration(), checkRange((endTime - + startTime), (int)mvi.getTimelineDuration(), 10)); + } + } + + /** + * @param videoEditor + * @param fileName + * @param export_bitrate + * @param export_height + * @param startTime + * @param endTime + * @param vCodec + * @param aCodec + */ + public void validateExport(VideoEditor videoEditor, String fileName, + int export_height, int startTime, int endTime, int vCodec, int aCodec) { + File tempFile = new File(fileName); + assertEquals("Exported FileName", tempFile.exists(), true); + final MediaVideoItem mvi = createMediaItem(videoEditor, "m1", fileName, + MediaItem.RENDERING_MODE_BLACK_BORDER); + Log.i(TAG, "VideoCodec for file = " + fileName + + "\tExpected Video Codec = " + vCodec + "\tActual Video Codec = " + + mvi.getVideoType()); + assertEquals("Export: Video Codec Mismatch for file = " + fileName + + "\t<expected> " + vCodec + "\t<actual> " + mvi.getVideoType(), + vCodec, mvi.getVideoType()); + + Log.i(TAG, "AudioCodec for file = " + fileName + + "\tExpected Audio Codec = " + aCodec + "\tActual Audio Codec = " + + mvi.getAudioType()); + assertEquals("Export: Audio Codec Mismatch for file = " + fileName + + "\t<expected> " + aCodec + "\t<actual> " + mvi.getAudioType(), + aCodec, mvi.getAudioType()); + + Log.i(TAG, "Height for file = " + fileName + "\tExpected Height = " + + export_height + "\tActual VideoHeight = " + mvi.getHeight()); + assertEquals("Export: height Mismatch for file " + fileName + + "\t<expected> " + export_height + "\t<actual> " + mvi.getHeight(), + export_height, mvi.getHeight()); + if (startTime == 0) { + if (endTime != 0) { + Log.i(TAG, "TimeLine Expected = " + (startTime + endTime) + + "\t VideoTime= " + mvi.getTimelineDuration()); + assertTrue("Export :Timeline Duration Mismatch for file " + + fileName + "<expected> " + (startTime + endTime) + + "\t<actual> " + mvi.getTimelineDuration(), + checkRange((startTime + endTime), mvi.getTimelineDuration(), 10)); + } + } else { + Log.i(TAG, "TimeLine Expected = " + (endTime-startTime) + + "\t VideoTime= " + mvi.getTimelineDuration()); + assertTrue("Timeline Duration Mismatch for file " + fileName + + "<expected> " + (endTime - startTime) + "\t<actual> " + + mvi.getTimelineDuration(), checkRange((endTime - + startTime), mvi.getTimelineDuration(), 10)); + } + } + + /** + * Check file and deletes it. + * + * @param filename + */ + public void checkDeleteExistingFile(String filename) { + Log.i(TAG, ">>>>>>>>>>>>>>>>>>checkDeleteExistingFile = " + filename); + if (filename != null) { + File temp = new File(filename); + if (temp != null && temp.exists()) { + temp.delete(); + } + } + } + + /** + * This method creates a Directory and filename + * + * @param location This is path where the file is to be created + * "/sdcard/Output/" + * @return Path in form of /sdcard/Output/200910100000 + */ + public String createRandomFile(String location) { + Random randomGenerator = new Random(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssS"); + Date date = new Date(); + final String filePath = location + dateFormat.format(date) + + randomGenerator.nextInt(10); + Log.i(TAG, ">>>>>>>>>>>>>>>>createRandomFile Location= " + location + + "\t FilePath = " + filePath); + return filePath; + } + + /** + * This method recursively deletes all the file and directory + * + * @param directory where the files are located Example = "/sdcard/Input" + * @return boolean True if deletion is successful else False + */ + public boolean deleteProject(File directory) { + Log.i(TAG, ">>>>>>>>>>>>>>>>>>>>>>>>deleteProject directory= " + + directory.toString()); + if (directory.isDirectory()) { + String[] filesInDirecory = directory.list(); + for (int i = 0; i < filesInDirecory.length; i++) { + boolean success = deleteProject(new File(directory, + filesInDirecory[i])); + if (!success) { + return false; + } + } + } + return directory.delete(); + } + + /** + * This method compares the array of Integer from 0 - 100 + * + * @param data set of integer values received as progress + * @return true if sucess else false + */ + public boolean checkProgressCBValues(int[] data) { + boolean retFlag = false; + for (int i = 0; i < 100; i++) { + if (data[i] == 100) { + retFlag = true; + break; + } else { + retFlag = false; + } + } + return retFlag; + } +} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java new file mode 100644 index 0000000..6a87656 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java @@ -0,0 +1,2803 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.mediaframeworktest.functional; + +import java.io.File; +import java.util.List; + +import android.graphics.Bitmap; +import android.graphics.Rect; +import android.media.videoeditor.AudioTrack; +import android.media.videoeditor.EffectColor; +import android.media.videoeditor.EffectKenBurns; +import android.media.videoeditor.ExtractAudioWaveformProgressListener; +import android.media.videoeditor.MediaImageItem; +import android.media.videoeditor.MediaItem; +import android.media.videoeditor.MediaProperties; +import android.media.videoeditor.MediaVideoItem; +import android.media.videoeditor.OverlayFrame; +import android.media.videoeditor.Transition; +import android.media.videoeditor.TransitionAlpha; +import android.media.videoeditor.TransitionCrossfade; +import android.media.videoeditor.TransitionFadeBlack; +import android.media.videoeditor.TransitionSliding; +import android.media.videoeditor.VideoEditor; +import android.os.Environment; +import android.test.ActivityInstrumentationTestCase; +import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener; + +import android.util.Log; +import java.lang.annotation.Annotation; + +import com.android.mediaframeworktest.MediaFrameworkTest; +import android.test.suitebuilder.annotation.LargeTest; +import com.android.mediaframeworktest.VideoEditorHelper; + +public class VideoEditorAPITest extends + ActivityInstrumentationTestCase<MediaFrameworkTest> { + private final String TAG = "VideoEditorTest"; + + private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON; + + private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON; + + private final String PROJECT_CLASS_NAME = + "android.media.videoeditor.VideoEditorImpl"; + private VideoEditor mVideoEditor; + private VideoEditorHelper mVideoEditorHelper; + + public VideoEditorAPITest() { + super("com.android.mediaframeworktest", MediaFrameworkTest.class); + } + + @Override + protected void setUp() throws Exception { + // setup for each test case. + super.setUp(); + mVideoEditorHelper = new VideoEditorHelper(); + // Create a random String which will be used as project path, where all + // project related files will be stored. + final String projectPath = mVideoEditorHelper. + createRandomFile(PROJECT_LOCATION); + mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath); + } + + @Override + protected void tearDown() throws Exception { + mVideoEditorHelper.destroyVideoEditor(mVideoEditor); + // Clean the directory created as project path + mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath())); + System.gc(); + super.tearDown(); + } + + /** + * To Test Creation of Media Video Item. + */ + // TODO : remove TC_API_001 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItem() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode = + MediaItem.RENDERING_MODE_BLACK_BORDER; + + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + + assertTrue("Media Video ID", + mediaVideoItem1.getId().equals("mediaVideoItem1")); + assertTrue("Media Video Filename", + mediaVideoItem1.getFilename().equals(videoItemFileName)); + assertEquals("Media Video Rendering Mode", + videoItemRenderingMode, mediaVideoItem1.getRenderingMode()); + assertEquals("Media Video Item Duration", mediaVideoItem1.getDuration(), + mediaVideoItem1.getTimelineDuration()); + assertEquals("Media Video Overlay", 0, + mediaVideoItem1.getAllOverlays().size()); + assertEquals("Media Video Effect", 0, + mediaVideoItem1.getAllEffects().size()); + assertNull("Media Video Begin transition", + mediaVideoItem1.getBeginTransition()); + assertNull("Media Video End transition", + mediaVideoItem1.getEndTransition()); + mediaVideoItem1.setExtractBoundaries(1000,11000); + boolean flagForException = false; + if (mediaVideoItem1.getDuration() != + mediaVideoItem1.getTimelineDuration()) { + flagForException = true; + } + assertTrue("Media Video Item Duration & Timeline are same", + flagForException ); + } + + /** + * To test creation of Media Video Item with Set Extract Boundaries With Get + * the Begin and End Time. + */ + // TODO : remove TC_API_002 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemExtractBoundaries() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + + mediaVideoItem1.setExtractBoundaries(1000, 11000); + assertEquals("Media Item Duration = StoryBoard Duration", + mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); + try { + mediaVideoItem1.setExtractBoundaries(0, 100000000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Set Extract with Invalid Values endTime > FileDuration", + flagForException); + + flagForException = false; + try { + mediaVideoItem1.setExtractBoundaries(100000000, 11000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Set Extract with Invalid Values startTime > endTime", + flagForException); + + flagForException = false; + try { + mediaVideoItem1.setExtractBoundaries(0, 0); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Set Extract with Invalid Values startTime = endTime", + flagForException); + + mediaVideoItem1.setExtractBoundaries(1000, 10000); + assertTrue("Media Item Duration is still the same", + (mediaVideoItem1.getTimelineDuration() == + (mediaVideoItem1.getBoundaryEndTime()- + mediaVideoItem1.getBoundaryBeginTime())) ? true : false); + + mediaVideoItem1.setExtractBoundaries(1,mediaVideoItem1.getDuration()-1); + assertEquals("Media Item Start Time", 1, + mediaVideoItem1.getBoundaryBeginTime()); + assertEquals("Media Item End Time", (mediaVideoItem1.getDuration() - 1), + mediaVideoItem1.getBoundaryEndTime()); + + mediaVideoItem1.setExtractBoundaries(1, mediaVideoItem1.getDuration()); + assertEquals("Media Item Duration = StoryBoard Duration", + mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); + + mediaVideoItem1.setExtractBoundaries(0,mediaVideoItem1.getDuration()/2); + assertEquals("Media Item Duration = StoryBoard Duration", + mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); + + mediaVideoItem1.setExtractBoundaries(0, -1); + assertEquals("Media Item Duration = StoryBoard Duration", + mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); + } + + /** + * To test creation of Media Video Item with Set and Get rendering Mode + */ + // TODO : remove TC_API_003 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemRenderingModes() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode= MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING); + assertEquals("MediaVideo Item rendering Mode", + MediaItem.RENDERING_MODE_CROPPING, + mediaVideoItem1.getRenderingMode()); + try { + mediaVideoItem1.setRenderingMode( + MediaItem.RENDERING_MODE_CROPPING + 911); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Media Item Invalid rendering Mode", flagForException); + flagForException = false; + try { + mediaVideoItem1.setRenderingMode( + MediaItem.RENDERING_MODE_BLACK_BORDER - 11); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Media Item Invalid rendering Mode", flagForException); + assertEquals("MediaVideo Item rendering Mode", + MediaItem.RENDERING_MODE_CROPPING, + mediaVideoItem1.getRenderingMode()); + mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH); + assertEquals("MediaVideo Item rendering Mode", + MediaItem.RENDERING_MODE_STRETCH, + mediaVideoItem1.getRenderingMode()); + } + + /** Test Case TC_API_004 is removed */ + + /** + * To Test the Media Video API : Set Audio Volume, Get Audio Volume and Mute + */ + // TODO : remove TC_API_005 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemAudioFeatures() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + mediaVideoItem1.setVolume(77); + assertEquals("Updated Volume is 77", 77, mediaVideoItem1.getVolume()); + + mediaVideoItem1.setMute(true); + assertTrue("Audio must be Muted", mediaVideoItem1.isMuted()); + + mediaVideoItem1.setVolume(78); + assertEquals("Updated Volume is 78", 78, mediaVideoItem1.getVolume()); + assertTrue("Audio must be Muted", mediaVideoItem1.isMuted()); + + try { + mediaVideoItem1.setVolume(1000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Invalid Set Volume", flagForException); + + mediaVideoItem1.setMute(false); + assertFalse("Audio must be Un-Muted", mediaVideoItem1.isMuted()); + + mediaVideoItem1.setVolume(0); + assertFalse("Audio must be Un-Muted", mediaVideoItem1.isMuted()); + + flagForException = false; + try { + mediaVideoItem1.setVolume(-1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Invalid Set Volume", flagForException); + + mediaVideoItem1.setVolume(100); + assertEquals("MediaItem Volume", 100, mediaVideoItem1.getVolume()); + try { + mediaVideoItem1.setVolume(101); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Invalid Set Volume", flagForException); + assertEquals("MediaItem Volume", 100, mediaVideoItem1.getVolume()); + } + + /** + * To Test the Media Video API : GetWaveFormData and + * extractAudioWaveFormData + */ + + // TODO : remove TC_API_006 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemGetWaveformData() throws Exception { + + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + + assertNull("WaveForm data", mediaVideoItem1.getWaveformData()); + final int[] progressWaveform = new int[105]; + + mediaVideoItem1.extractAudioWaveform(new + ExtractAudioWaveformProgressListener() { + int i = 0; + public void onProgress(int progress) { + Log.i("WaveformData","progress=" +progress); + progressWaveform[i++] = progress; + } + }); + assertTrue("Progress of WaveForm data", mVideoEditorHelper + .checkProgressCBValues(progressWaveform)); + assertNotNull("WaveForm data", mediaVideoItem1.getWaveformData()); + assertTrue("WaveForm Frame Duration", + (mediaVideoItem1.getWaveformData().getFrameDuration() > 0? + true : false)); + assertTrue("WaveForm Frame Count", + (mediaVideoItem1.getWaveformData().getFramesCount() > 0 ? + true : false)); + assertTrue("WaveForm Gain", + (mediaVideoItem1.getWaveformData().getFrameGains().length > 0 ? + true : false)); + + } + + /** + * To Test the Media Video API : Get Effect, GetAllEffects, remove Effect + */ + + // TODO : remove TC_API_007 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemEffect() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper. + createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, + videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + + assertTrue("Effect List Size", + (mediaVideoItem1.getAllEffects().size() == 0) ? true : false); + assertNull("Effect Item by ID", mediaVideoItem1.getEffect("xyx")); + + final EffectColor effectColor = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, + EffectColor.GRAY); + mediaVideoItem1.addEffect(effectColor); + + assertTrue("Effect List Size", (mediaVideoItem1. + getAllEffects().size() == 1) ? true : false); + assertEquals("Effect Item by Valid ID", effectColor, + mediaVideoItem1.getEffect(effectColor.getId())); + assertNull("Effect Item by Invalid ID", + mediaVideoItem1.getEffect("xyz")); + assertNull("Effect Item by Invalid ID", + mediaVideoItem1.removeEffect("effectId")); + assertTrue("Effect List Size", + (mediaVideoItem1.getAllEffects().size() == 1) ? true : false); + assertEquals("Effect Removed", effectColor, + mediaVideoItem1.removeEffect(effectColor.getId())); + assertTrue("Effect List Size", + (mediaVideoItem1.getAllEffects().size() == 0) ? true : false); + assertNull("Effect Item by ID", mediaVideoItem1.getEffect("effectId")); + } + + /** + * To Test the Media Video API : Get Before and after transition + */ + + // TODO : remove TC_API_008 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemTransitions() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + assertNull("Begin Transition", mediaVideoItem1.getBeginTransition()); + assertNull("End Transition", mediaVideoItem1.getEndTransition()); + + TransitionFadeBlack transition1 = + mVideoEditorHelper.createTFadeBlack("transition1", mediaVideoItem1, + null, 0, Transition.BEHAVIOR_SPEED_UP); + mVideoEditor.addTransition(transition1); + assertEquals("Begin transition", transition1, + mediaVideoItem1.getEndTransition()); + + assertNotNull("End Transition", mediaVideoItem1.getEndTransition()); + assertTrue(mediaVideoItem1. + getEndTransition().getId().equals(transition1.getId())); + assertTrue(mediaVideoItem1.getEndTransition().getDuration() == + transition1.getDuration() ? true : false); + assertTrue(mediaVideoItem1.getEndTransition().getBehavior() == + transition1.getBehavior() ? true : false); + + TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack( + "transition2", null,mediaVideoItem1, 0, Transition.BEHAVIOR_LINEAR); + mVideoEditor.addTransition(transition2); + assertNotNull("Begin transition", mediaVideoItem1.getBeginTransition()); + assertEquals("End Transition", transition2, + mediaVideoItem1.getBeginTransition()); + assertTrue(mediaVideoItem1. + getBeginTransition().getId().equals(transition2.getId())); + assertTrue(mediaVideoItem1. getBeginTransition().getDuration() == + transition2.getDuration() ? true : false); + assertTrue(mediaVideoItem1.getBeginTransition().getBehavior() == + transition2.getBehavior() ? true : false); + } + + /** + * To Test the Media Video API : Get All Overlay, Get Overlay and remove Overlay + * + */ + + // TODO : remove TC_API_009 + @SuppressWarnings("unused") + @LargeTest + public void testMediaVideoItemOverlays() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; + final String overlayItemFileName = INPUT_FILE_PATH + + "IMG_176x144_Overlay1.png"; + final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + + assertTrue("Overlay List Size", + (mediaVideoItem1.getAllOverlays().size() == 0) ? true : false); + assertNull("Overlay Item by ID", mediaVideoItem1.getOverlay("xyz")); + + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, + 176, 144); + final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay( + mediaVideoItem1, "overlayId", mBitmap, 5000, 5000); + mediaVideoItem1.addOverlay(overlayFrame); + + assertTrue("Overlay List Size", + (mediaVideoItem1.getAllOverlays().size() == 1) ? true : false); + assertEquals("Overlay Item by Valid ID", overlayFrame, mediaVideoItem1 + .getOverlay(overlayFrame.getId())); + assertNull("Overlay Item by Invalid ID", + mediaVideoItem1.getOverlay("xyz")); + assertNull("Overlay Item by Invalid ID", + mediaVideoItem1.removeOverlay("xyz")); + assertTrue("Overlay List Size", + (mediaVideoItem1.getAllOverlays().size() == 1) ? true : false); + assertEquals("Overlay Removed", overlayFrame, + mediaVideoItem1.removeOverlay(overlayFrame.getId())); + assertTrue("Overlay List Size", + (mediaVideoItem1.getAllOverlays().size() == 0) ? true : false); + assertNull("Overlay Item by ID",mediaVideoItem1.getOverlay("effectId")); + } + + /** + * To Test Creation of Media Image Item. + */ + // TODO : remove TC_API_010 + @LargeTest + public void testMediaImageItem() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 5000, imageItemRenderingMode); + assertTrue("Media Image ID", + mediaImageItem1.getId().equals("mediaImageItem1")); + assertTrue("Media IMage Filename", + mediaImageItem1.getFilename().equals(imageItemFileName)); + assertEquals("Media Image Rendering Mode", + imageItemRenderingMode, mediaImageItem1.getRenderingMode()); + assertEquals("Media Image Item Duration", mediaImageItem1.getDuration(), + mediaImageItem1.getTimelineDuration()); + assertEquals("Media Image Overlay", 0, + mediaImageItem1.getAllOverlays().size()); + assertEquals("Media Image Effect", 0, + mediaImageItem1.getAllEffects().size()); + assertNull("Media Image Begin transition", + mediaImageItem1.getBeginTransition()); + assertNull("Media Image End transition", + mediaImageItem1.getEndTransition()); + assertEquals("Media Image Scaled Height", MediaProperties.HEIGHT_720, + mediaImageItem1.getScaledHeight()); + assertEquals("Media Image Scaled Width", 960, + mediaImageItem1.getScaledWidth()); + assertEquals("Media Image Aspect Ratio", MediaProperties.ASPECT_RATIO_4_3, + mediaImageItem1.getAspectRatio()); + assertNotNull("Media Image Thumbnail", + mediaImageItem1.getThumbnail(960, MediaProperties.HEIGHT_720, 2000)); + } + + /** + * To Test the Media Image API : Get and Set rendering Mode + */ + // TODO : remove TC_API_011 + @LargeTest + public void testMediaImageItemRenderingModes() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; + final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, imageItemRenderingMode, 5000); + mVideoEditor.addMediaItem(mediaImageItem1); + + mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING); + assertEquals("MediaVideo Item rendering Mode", + MediaItem.RENDERING_MODE_CROPPING, mediaImageItem1.getRenderingMode()); + try { + mediaImageItem1.setRenderingMode( + MediaItem.RENDERING_MODE_CROPPING + 911); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Media Item Invalid rendering Mode", flagForException); + + flagForException = false; + try { + mediaImageItem1.setRenderingMode( + MediaItem.RENDERING_MODE_BLACK_BORDER - 11); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Media Item Invalid rendering Mode", flagForException); + + assertEquals("MediaVideo Item rendering Mode", + MediaItem.RENDERING_MODE_CROPPING, + mediaImageItem1.getRenderingMode()); + mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH); + assertEquals("MediaVideo Item rendering Mode", + MediaItem.RENDERING_MODE_STRETCH, + mediaImageItem1.getRenderingMode()); + } + + /** + * To Test the Media Image API : GetHeight and GetWidth + */ + // TODO : remove TC_API_012 + @LargeTest + public void testMediaImageItemHeightWidth() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, imageItemRenderingMode, 5000); + mVideoEditor.addMediaItem(mediaImageItem1); + + assertEquals("Image Height = Image Scaled Height", + mediaImageItem1.getScaledHeight(), mediaImageItem1.getHeight()); + assertEquals("Image Width = Image Scaled Width", + mediaImageItem1.getScaledWidth(), mediaImageItem1.getWidth()); + } + + + +/** This Test Case can be removed as this is already checked in TC 010 */ + /** + * To Test the Media Image API : Scaled Height and Scaled GetWidth + */ + // TODO : remove TC_API_013 + @LargeTest + public void testMediaImageItemScaledHeightWidth() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, imageItemRenderingMode, 5000); + mVideoEditor.addMediaItem(mediaImageItem1); + + assertNotSame("Image Height = Image Scaled Height", + mediaImageItem1.getScaledHeight(), mediaImageItem1.getHeight()); + assertNotSame("Image Width = Image Scaled Width", + mediaImageItem1.getScaledWidth(), mediaImageItem1.getWidth()); + } + + /** + * To Test the Media Image API : Get Effect, GetAllEffects, remove Effect + */ + + // TODO : remove TC_API_014 + @LargeTest + public void testMediaImageItemEffect() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 5000, imageItemRenderingMode); + mVideoEditor.addMediaItem(mediaImageItem1); + + assertTrue("Effect List Size", + (mediaImageItem1.getAllEffects().size() == 0) ? true : false); + assertNull("Effect Item by ID", mediaImageItem1.getEffect("xyx")); + + final EffectColor effectColor = + mVideoEditorHelper.createEffectItem(mediaImageItem1, + "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY); + mediaImageItem1.addEffect(effectColor); + + assertTrue("Effect List Size", + (mediaImageItem1.getAllEffects().size() == 1) ? true : false); + assertEquals("Effect Item by Valid ID", + effectColor, mediaImageItem1.getEffect(effectColor.getId())); + assertNull("Effect Item by Invalid ID", + mediaImageItem1.getEffect("xyz")); + assertNull("Effect Item by Invalid ID", + mediaImageItem1.removeEffect("effectId")); + assertTrue("Effect List Size", + (mediaImageItem1.getAllEffects().size() == 1) ? true : false); + assertEquals("Effect Removed", effectColor, + mediaImageItem1.removeEffect(effectColor.getId())); + assertTrue("Effect List Size", + (mediaImageItem1.getAllEffects().size() == 0) ? true : false); + assertNull("Effect Item by ID", mediaImageItem1.getEffect("effectId")); + } + + /** + * To Test the Media Image API : Get Before and after transition + */ + + // TODO : remove TC_API_015 + @LargeTest + public void testMediaImageItemTransitions() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 5000, imageItemRenderingMode); + mVideoEditor.addMediaItem(mediaImageItem1); + + assertNull("Begin Transition", mediaImageItem1.getBeginTransition()); + assertNull("End Transition", mediaImageItem1.getEndTransition()); + + TransitionFadeBlack transition1 = + mVideoEditorHelper.createTFadeBlack("transition1", mediaImageItem1, + null, 0, Transition.BEHAVIOR_SPEED_UP); + mVideoEditor.addTransition(transition1); + + assertEquals("Begin transition", transition1, + mediaImageItem1.getEndTransition()); + assertNotNull("End Transition", mediaImageItem1.getEndTransition()); + assertTrue(mediaImageItem1.getEndTransition().getId().equals + (transition1.getId())); + assertTrue(mediaImageItem1.getEndTransition().getDuration() == + transition1.getDuration() ? true : false); + assertTrue(mediaImageItem1.getEndTransition().getBehavior() == + transition1.getBehavior() ? true : false); + + TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack( + "transition2",null, mediaImageItem1, 0, Transition.BEHAVIOR_SPEED_UP); + mVideoEditor.addTransition(transition2); + + assertNotNull("Begin transition", mediaImageItem1.getBeginTransition()); + assertEquals("End Transition", transition2, + mediaImageItem1.getBeginTransition()); + assertTrue(mediaImageItem1.getBeginTransition().getId().equals( + transition2.getId())); + assertTrue(mediaImageItem1.getBeginTransition().getDuration() == + transition2.getDuration() ? true : false); + assertTrue(mediaImageItem1.getBeginTransition().getBehavior() == + transition2.getBehavior() ? true : false); + } + + /** + * To Test the Media Image API : Get All Overlay, Get Overlay and remove + * Overlay + */ + + // TODO : remove TC_API_016 + @LargeTest + public void testMediaImageItemOverlays() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final String overlayItemFileName = INPUT_FILE_PATH + + "IMG_640x480_Overlay1.png"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 12000, imageItemRenderingMode); + mVideoEditor.addMediaItem(mediaImageItem1); + + assertTrue("Overlay List Size", + (mediaImageItem1.getAllOverlays().size() == 0) ? true : false); + assertNull("Overlay Item by ID", mediaImageItem1.getOverlay("xyz")); + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, + 640, 480); + final OverlayFrame overlayFrame = + mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId", + mBitmap, 5000, 5000); + mediaImageItem1.addOverlay(overlayFrame); + + assertTrue("Overlay List Size", + (mediaImageItem1.getAllOverlays().size() == 1) ? true : false); + assertEquals("Overlay Item by Valid ID", overlayFrame, mediaImageItem1 + .getOverlay(overlayFrame.getId())); + assertNull("Overlay Item by Invalid ID", + mediaImageItem1.getOverlay("xyz")); + assertNull("Remove Overlay Item by Invalid ID", + mediaImageItem1.removeOverlay("xyz")); + assertTrue("Overlay List Size", + (mediaImageItem1.getAllOverlays().size() == 1) ? true : false); + assertEquals("Overlay Removed", + overlayFrame, mediaImageItem1.removeOverlay(overlayFrame.getId())); + assertTrue("Overlay List Size", + (mediaImageItem1.getAllOverlays().size() == 0) ? true : false); + assertNull("Overlay Item by ID", + mediaImageItem1.getOverlay("effectId")); + } + + /** + * To test creation of Audio Track + */ + + // TODO : remove TC_API_017 + @LargeTest + public void testAudioTrack() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + + assertEquals("Audio Track Item Duration", audioTrack.getDuration(), + audioTrack.getTimelineDuration()); + assertEquals("Audio Track Start Time", 0, audioTrack.getStartTime()); + assertFalse("Audio Track is Looping", audioTrack.isLooping()); + audioTrack.getVolume(); + assertFalse("Audio Track Ducking is Disabled", + audioTrack.isDuckingEnabled()); + assertTrue("Audio Track Filename", + audioTrack.getFilename().equals(audioFileName)); + assertEquals("Audio Ducking Threshold", 0, + audioTrack.getDuckingThreshhold()); + assertFalse("Audio Track Mute", audioTrack.isMuted()); + audioTrack.getDuckedTrackVolume(); + } + + /** + * To test creation of Audio Track with set extract boundaries + */ + // TODO : remove TC_API_018 + @LargeTest + public void testAudioTrackExtractBoundaries() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + boolean flagForException = false; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + + audioTrack.setExtractBoundaries(1000, 5000); + assertEquals("Audio Track Start time", 1000, + audioTrack.getBoundaryBeginTime()); + assertEquals("Audio Track End time", 5000, + audioTrack.getBoundaryEndTime()); + try { + audioTrack.setExtractBoundaries(0, 100000000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Audio Track With endTime > FileDuration", flagForException); + flagForException = false; + try { + audioTrack.setExtractBoundaries(100000000, 5000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Audio Track With startTime > FileDuration", + flagForException); + flagForException = false; + try { + audioTrack.setExtractBoundaries(0, 0); + } catch (IllegalArgumentException e) { + flagForException = true; + } + /* This is under discussion. Hence, checked for False */ + assertFalse("Audio Track With startTime = endTime", flagForException); + assertEquals("Audio Track Start time", 0, + audioTrack.getBoundaryBeginTime()); + assertEquals("Audio Track End time", 0, + audioTrack.getBoundaryEndTime()); + assertEquals("Audio Track Start time",0, + audioTrack.getBoundaryBeginTime()); + assertEquals("Audio Track End time", (audioTrack.getTimelineDuration()), + audioTrack.getBoundaryEndTime()); + audioTrack.setExtractBoundaries(0, audioTrack.getDuration() / 2); + assertEquals("Audio Track Start time",0, + audioTrack.getBoundaryBeginTime()); + assertEquals("Audio Track End time", (audioTrack.getDuration() / 2), + audioTrack.getBoundaryEndTime()); + audioTrack.setExtractBoundaries(1, audioTrack.getDuration() - 1); + assertEquals("Audio Track Start time", 1, + audioTrack.getBoundaryBeginTime()); + assertEquals("Audio Track End time", (audioTrack.getDuration() - 1), + audioTrack.getBoundaryEndTime()); + + flagForException = false; + try { + audioTrack.setExtractBoundaries(0, -1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue ("Audio Track end time < 0",flagForException); + } + + /** + * To test creation of Audio Track with set Start Time and Get Time + */ + // TODO : remove TC_API_019 + @LargeTest + public void testAudioTrackSetGetTime() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + boolean flagForException = false; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + /** set StartTime API is removed and start time is always 0 */ + assertEquals("Audio Track Start Time", 0, audioTrack.getStartTime()); + } + + /** + * To Test the Audio Track API: Enable Ducking + */ + // TODO : remove TC_API_020 + @LargeTest + public void testAudioTrackEnableDucking() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + boolean flagForException = false; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + + assertFalse("Audio Ducking Disabled by default", + audioTrack.isDuckingEnabled()); + audioTrack.enableDucking(45, 70); + assertTrue("Audio Ducking Enabled", audioTrack.isDuckingEnabled()); + assertEquals("Audio Ducking Threshold", 45, + audioTrack.getDuckingThreshhold()); + assertEquals("Audio Ducking Volume", 70, + audioTrack.getDuckedTrackVolume()); + audioTrack.enableDucking(85, 70); + assertEquals("Audio Ducking Threshold", 85, + audioTrack.getDuckingThreshhold()); + assertEquals("Audio Ducking Volume", 70, + audioTrack.getDuckedTrackVolume()); + try { + audioTrack.enableDucking(91, 70); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Enable ducking threshold > 90", flagForException); + flagForException = false; + try { + audioTrack.enableDucking(90, 101); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Enable ducking volume > 100", flagForException); + flagForException = false; + try { + audioTrack.enableDucking(91, 101); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Enable ducking volume > 100 and threshold > 91", + flagForException); + flagForException = false; + try { + audioTrack.enableDucking(-1, 100); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Enable ducking threshold < 0", flagForException); + flagForException = false; + try { + audioTrack.enableDucking(1, -1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Enable ducking lowVolume < 0", flagForException); + flagForException = false; + try { + audioTrack.enableDucking(0, 50); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertFalse("Enable ducking threshold = 0", flagForException); + } + + /** + * To Test the Audio Track API: Looping + */ + // TODO : remove TC_API_021 + @LargeTest + public void testAudioTrackLooping() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + assertFalse("Audio Looping", audioTrack.isLooping()); + audioTrack.enableLoop(); + assertTrue("Audio Looping", audioTrack.isLooping()); + audioTrack.disableLoop(); + assertFalse("Audio Looping", audioTrack.isLooping()); + } + + /** + * To Test the Audio Track API:Extract waveform data + */ + // TODO : remove TC_API_022 + + @LargeTest + public void testAudioTrackWaveFormData() throws Exception { + /** Image item is added as dummy as Audio track cannot be added without + * a media item in the story board + */ + final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 5000, imageItemRenderingMode); + mVideoEditor.addMediaItem(mediaImageItem); + + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + + mVideoEditor.addAudioTrack(audioTrack); + assertNull("WaveForm data", audioTrack.getWaveformData()); + + final int[] progressUpdate = new int[105]; + mVideoEditor.generatePreview(new MediaProcessingProgressListener() { + int i = 0; + public void onProgress(Object item, int action, int progress) { + progressUpdate[i++] = progress; + } + }); + + final int[] progressWaveform = new int[105]; + + audioTrack.extractAudioWaveform( + new ExtractAudioWaveformProgressListener() { + int i = 0; + public void onProgress(int progress) { + Log.i("AudioWaveformData","progress=" +progress); + progressWaveform[i++] = progress; + } + }); + assertTrue("Progress of WaveForm data", mVideoEditorHelper + .checkProgressCBValues(progressWaveform)); + assertNotNull("WaveForm data", audioTrack.getWaveformData()); + assertTrue("WaveForm Frame Duration", + (audioTrack.getWaveformData().getFrameDuration() > 0 ? + true : false)); + assertTrue("WaveForm Frame Count", + (audioTrack.getWaveformData().getFramesCount() > 0 ? true : false)); + assertTrue("WaveForm Gain", + (audioTrack.getWaveformData().getFrameGains().length > 0 ? + true : false)); + } + + /** + * To Test the Audio Track API: Mute + */ + // TODO : remove TC_API_023 + @LargeTest + public void testAudioTrackMute() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + assertFalse("Audio Track UnMute", audioTrack.isMuted()); + audioTrack.setMute(true); + assertTrue("Audio Track Mute", audioTrack.isMuted()); + audioTrack.setMute(false); + assertFalse("Audio Track UnMute", audioTrack.isMuted()); + } + + /** + * To Test the Audio Track API: Get Volume and Set Volume + */ + // TODO : remove TC_API_024 + @LargeTest + public void testAudioTrackGetSetVolume() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + boolean flagForException = false; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + audioTrack.setVolume(0); + assertEquals("Audio Volume", 0, audioTrack.getVolume()); + assertFalse("Audio Track UnMute", audioTrack.isMuted()); + audioTrack.setVolume(45); + assertEquals("Audio Volume", 45, audioTrack.getVolume()); + assertFalse("Audio Track UnMute", audioTrack.isMuted()); + try { + audioTrack.setVolume(-1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Volume = -1", flagForException); + assertEquals("Audio Volume", 45, audioTrack.getVolume()); + flagForException = false; + try { + audioTrack.setVolume(101); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Volume = 101", flagForException); + flagForException = false; + try { + audioTrack.setVolume(1000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Volume = 10000", flagForException); + assertEquals("Audio Volume", 45, audioTrack.getVolume()); + } + + /** + * To test Effect Color. + */ + // TODO : remove TC_API_025 + @LargeTest + public void testAllEffects() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4"; + boolean flagForException = false; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaVideoItem1); + + final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect1", 1000, 1000, EffectColor.TYPE_COLOR, + EffectColor.PINK); + mediaVideoItem1.addEffect(effectColor1); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor1.getMediaItem()); + assertTrue("Effect Id", effectColor1.getId().equals("effect1")); + assertEquals("Effect StartTime", 1000, effectColor1.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor1.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_COLOR, + effectColor1.getType()); + assertEquals("Effect Color", EffectColor.PINK, effectColor1.getColor()); + + final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect2", 2000, 1000, EffectColor.TYPE_COLOR, + EffectColor.GRAY); + mediaVideoItem1.addEffect(effectColor2); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor2.getMediaItem()); + assertTrue("Effect Id", effectColor2.getId().equals("effect2")); + assertEquals("Effect StartTime", 2000, effectColor2.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor2.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_COLOR, + effectColor2.getType()); + assertEquals("Effect Color", EffectColor.GRAY, effectColor2.getColor()); + + final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect3", 3000, 1000, EffectColor.TYPE_COLOR, + EffectColor.GREEN); + mediaVideoItem1.addEffect(effectColor3); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor3.getMediaItem()); + assertTrue("Effect Id", effectColor3.getId().equals("effect3")); + assertEquals("Effect StartTime", 3000, effectColor3.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor3.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_COLOR, + effectColor3.getType()); + assertEquals("Effect Color", EffectColor.GREEN, effectColor3.getColor()); + + final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect4", 4000, 1000, EffectColor.TYPE_GRADIENT, + EffectColor.PINK); + mediaVideoItem1.addEffect(effectColor4); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor4.getMediaItem()); + assertTrue("Effect Id", effectColor4.getId().equals("effect4")); + assertEquals("Effect StartTime", 4000, effectColor4.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor4.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, + effectColor4.getType()); + assertEquals("Effect Color", EffectColor.PINK, effectColor4.getColor()); + + final EffectColor effectColor5 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect5", 5000, 1000, + EffectColor.TYPE_GRADIENT, EffectColor.GRAY); + mediaVideoItem1.addEffect(effectColor5); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor5.getMediaItem()); + assertTrue("Effect Id", effectColor5.getId().equals("effect5")); + assertEquals("Effect StartTime", 5000, effectColor5.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor5.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, + effectColor5.getType()); + assertEquals("Effect Color", EffectColor.GRAY, effectColor5.getColor()); + + final EffectColor effectColor6 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect6", 6000, 1000, + EffectColor.TYPE_GRADIENT, EffectColor.GREEN); + mediaVideoItem1.addEffect(effectColor6); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor6.getMediaItem()); + assertTrue("Effect Id", effectColor6.getId().equals("effect6")); + assertEquals("Effect StartTime", 6000, effectColor6.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor6.getDuration()); + assertEquals("Effect Type", + EffectColor.TYPE_GRADIENT, effectColor6.getType()); + assertEquals("Effect Color", + EffectColor.GREEN, effectColor6.getColor()); + + final EffectColor effectColor7 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect7", 7000, 1000, + EffectColor.TYPE_FIFTIES, 0); + mediaVideoItem1.addEffect(effectColor7); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor7.getMediaItem()); + assertTrue("Effect Id", effectColor7.getId().equals("effect7")); + assertEquals("Effect StartTime", 7000, effectColor7.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor7.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_FIFTIES, + effectColor7.getType()); + assertEquals("Effect Color", -1, effectColor7.getColor()); + + final EffectColor effectColor8 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect8", 8000, 1000, EffectColor.TYPE_SEPIA, 0); + mediaVideoItem1.addEffect(effectColor8); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor8.getMediaItem()); + assertTrue("Effect Id", effectColor8.getId().equals("effect8")); + assertEquals("Effect StartTime", 8000, effectColor8.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor8.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_SEPIA, + effectColor8.getType()); + assertEquals("Effect Color", -1, effectColor8.getColor()); + + final EffectColor effectColor9 = mVideoEditorHelper.createEffectItem( + mediaVideoItem1, "effect9", 9000, 1000, + EffectColor.TYPE_NEGATIVE, 0); + mediaVideoItem1.addEffect(effectColor9); + + assertEquals("Associated Media Item", mediaVideoItem1, + effectColor9.getMediaItem()); + assertTrue("Effect Id", effectColor9.getId().equals("effect9")); + assertEquals("Effect StartTime", 9000, effectColor9.getStartTime()); + assertEquals("Effect EndTime", 1000, effectColor9.getDuration()); + assertEquals("Effect Type", EffectColor.TYPE_NEGATIVE, + effectColor9.getType()); + assertEquals("Effect Color", -1, effectColor9.getColor()); + try { + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", + 9000, 1000, EffectColor.TYPE_COLOR - 1, 0); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect type Invalid", flagForException); + flagForException = false; + try { + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", + 9000, 1000, EffectColor.TYPE_FIFTIES + 1, 0); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect type Invalid", flagForException); + try { + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect10", + 10000, 1000, EffectColor.TYPE_FIFTIES + + EffectColor.TYPE_GRADIENT, 0); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect type Invalid", flagForException); + } + + /** + * To test Effect Color : Set duration and Get Duration + */ + // TODO : remove TC_API_026 + @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); + } + + /** + * To test Effect Color : UNDEFINED color param value + */ + // TODO : remove TC_API_027 + @LargeTest + public void testEffectUndefinedColorParam() 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); + try{ + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 1000, + 2000, EffectColor.TYPE_COLOR, 0xabcdabcd); + }catch (IllegalArgumentException e){ + flagForException = true; + } + assertTrue("Invalid Effect added",flagForException); + } + + /** + * To test Effect Color : with Invalid StartTime and Duration + */ + // TODO : remove TC_API_028 + @LargeTest + public void testEffectInvalidStartTimeAndDuration() throws Exception { + final String videoItemFileName = INPUT_FILE_PATH + + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp"; + final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", + videoItemFileName, videoItemRenderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + + try { + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", + 400000000, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect with invalid StartTime", flagForException); + + flagForException = false; + try { + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", -1, + 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect with invalid StartTime", flagForException); + + flagForException = false; + try { + mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", + 2000, -1, EffectColor.TYPE_COLOR, EffectColor.GREEN); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect with invalid Duration", flagForException); + } + + + /** Test cases 29, 30, 31, 32 and 33 are removed */ + + + /** + * To test Effect : with NULL Media Item + */ + // TODO : remove TC_API_034 + @LargeTest + public void testEffectNullMediaItem() throws Exception { + boolean flagForException = false; + try { + mVideoEditorHelper.createEffectItem(null, "effect1", 1000, 4000, + EffectColor.TYPE_COLOR, EffectColor.GREEN); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Effect with null MediaItem", flagForException); + } + + /** + * To test Effect : KenBurn Effect + */ + // TODO : remove TC_API_035 + @LargeTest + public void testEffectKenBurn() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaImageItem mediaImageItem = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 5000, imageItemRenderingMode); + mVideoEditor.addMediaItem(mediaImageItem); + + final Rect startRect = new Rect((mediaImageItem.getHeight() / 3), + (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2), + (mediaImageItem.getWidth() / 2)); + final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(), + mediaImageItem.getHeight()); + + final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns( + mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000); + + assertNotNull("EffectKenBurns", kbEffectOnMediaItem); + mediaImageItem.addEffect(kbEffectOnMediaItem); + assertEquals("KenBurn Start Rect", startRect, + kbEffectOnMediaItem.getStartRect()); + assertEquals("KenBurn End Rect", endRect, + kbEffectOnMediaItem.getEndRect()); + } + + /** + * To test KenBurnEffect : Set StartRect and EndRect + */ + + // TODO : remove TC_API_036 + @LargeTest + public void testEffectKenBurnSet() throws Exception { + final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + final MediaImageItem mediaImageItem = + mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", + imageItemFileName, 5000, imageItemRenderingMode); + mVideoEditor.addMediaItem(mediaImageItem); + + final Rect startRect = new Rect((mediaImageItem.getHeight() / 3), + (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2), + (mediaImageItem.getWidth() / 2)); + final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(), + mediaImageItem.getHeight()); + + EffectKenBurns kbEffectOnMediaItem=null; + kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2", + startRect, endRect, 500, 3000); + + assertNotNull("EffectKenBurns", kbEffectOnMediaItem); + mediaImageItem.addEffect(kbEffectOnMediaItem); + assertEquals("KenBurn Start Rect", startRect, + kbEffectOnMediaItem.getStartRect()); + assertEquals("KenBurn End Rect", endRect, + kbEffectOnMediaItem.getEndRect()); + + final Rect startRect1 = new Rect((mediaImageItem.getHeight() / 5), + (mediaImageItem.getWidth() / 5), (mediaImageItem.getHeight() / 4), + (mediaImageItem.getWidth() / 4)); + final Rect endRect1 = new Rect(10, 10, mediaImageItem.getWidth() / 4, + mediaImageItem.getHeight() / 4); + + //kbEffectOnMediaItem.setStartRect(startRect1); + //kbEffectOnMediaItem.setEndRect(endRect1); + /* Added newly to take care of removal set APIs */ + kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_changed", + startRect1, endRect1, 500, 3000); + + assertEquals("KenBurn Start Rect", startRect1, + kbEffectOnMediaItem.getStartRect()); + assertEquals("KenBurn End Rect", endRect1, + kbEffectOnMediaItem.getEndRect()); + + final Rect zeroRect = new Rect(0, 0, 0, 0); + try { + //kbEffectOnMediaItem.setStartRect(zeroRect); + kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroStart", + zeroRect, endRect, 500, 3000); + + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Invalid Start Rect", flagForException); + + flagForException = false; + try { + //kbEffectOnMediaItem.setEndRect(zeroRect); + kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroEnd", + startRect, zeroRect, 500, 3000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Invalid End Rect", flagForException); + } + + /** + * To test Transition : Fade To Black with all behavior + * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST + */ + + // TODO : remove TC_API_037 + @SuppressWarnings("unused") + @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); + } + + /** + * To test Transition : CrossFade with all behavior + * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST + */ + + // TODO : remove TC_API_038 + @SuppressWarnings("unused") + @LargeTest + public void testTransitionCrossFade() 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 TransitionCrossfade transition1And2 = + mVideoEditorHelper.createTCrossFade("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 TransitionCrossfade transition2And3 = + mVideoEditorHelper.createTCrossFade("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, 18000); + mVideoEditor.addMediaItem(mediaVideoItem4); + + final TransitionCrossfade transition3And4 = + mVideoEditorHelper.createTCrossFade("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 TransitionCrossfade transition4And5 = + mVideoEditorHelper.createTCrossFade("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 TransitionCrossfade transition5And6 = + mVideoEditorHelper.createTCrossFade("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.createTCrossFade("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.createTCrossFade("transitiond6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition FadeBlack with Invalid behavior", flagForException); + } + + /** + * To test Transition : Sliding with all behavior + * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST and Direction = + * DIRECTION_RIGHT_OUT_LEFT_IN + * ,DIRECTION_LEFT_OUT_RIGHT_IN,DIRECTION_TOP_OUT_BOTTOM_IN + * ,DIRECTION_BOTTOM_OUT_TOP_IN + */ + + // TODO : remove TC_API_039 + @SuppressWarnings("unused") + @LargeTest + public void testTransitionSliding() 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 TransitionSliding transition1And2 = + mVideoEditorHelper.createTSliding("transition1And2", mediaVideoItem1, + mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP, + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); + 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()); + assertEquals("Transition Sliding", + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN, + transition1And2.getDirection()); + + final MediaImageItem mediaImageItem3 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", + imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaImageItem3); + + final TransitionSliding transition2And3 = + mVideoEditorHelper.createTSliding("transition2And3", + mediaVideoItem2, mediaImageItem3, 1000, + Transition.BEHAVIOR_SPEED_DOWN, + TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN); + 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()); + assertEquals("Transition Sliding", + TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN, + transition2And3.getDirection()); + + final MediaVideoItem mediaVideoItem4 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", + videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaVideoItem4.setExtractBoundaries(0, 18000); + mVideoEditor.addMediaItem(mediaVideoItem4); + + final TransitionSliding transition3And4 = + mVideoEditorHelper.createTSliding("transition3And4", mediaImageItem3, + mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR, + TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN); + 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()); + assertEquals("Transition Sliding", + TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN, + transition3And4.getDirection()); + + final MediaVideoItem mediaVideoItem5 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", + videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaVideoItem5); + + final TransitionSliding transition4And5 = + mVideoEditorHelper.createTSliding("transition4And5", mediaVideoItem4, + mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST, + TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN); + 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()); + assertEquals("Transition Sliding", + TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN, + transition4And5.getDirection()); + + final MediaVideoItem mediaVideoItem6 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", + videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaVideoItem6.setExtractBoundaries(0, 20000); + mVideoEditor.addMediaItem(mediaVideoItem6); + + final TransitionSliding transition5And6 = + mVideoEditorHelper.createTSliding("transition5And6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); + 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()); + assertEquals("Transition Sliding", + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN, + transition5And6.getDirection()); + + flagForException = false; + try { + mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN - 1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition Sliding with Invalid Direction", flagForException); + flagForException = false; + try { + mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, + TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN + 1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition Sliding with Invalid behavior", flagForException); + flagForException = false; + try { + mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1, + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition Sliding with Invalid behavior", flagForException); + flagForException = false; + try { + mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, + TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition Sliding with Invalid behavior", flagForException); + } + + /** + * To test Transition : Alpha with all behavior + * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST + */ + + // TODO : remove TC_API_040 + @SuppressWarnings("unused") + @LargeTest + public void testTransitionAlpha() 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_640x480.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"; + final String maskFilename = INPUT_FILE_PATH + + "TransitionSpiral_QVGA.jpg"; + 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 TransitionAlpha transition1And2 = + mVideoEditorHelper.createTAlpha("transition1And2", mediaVideoItem1, + mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP, maskFilename, + 10, false); + 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()); + assertTrue("Transition maskFile", + transition1And2.getMaskFilename().equals(maskFilename)); + assertEquals("Transition BlendingPercent", 10, + transition1And2.getBlendingPercent()); + assertFalse("Transition Invert", transition1And2.isInvert()); + + final MediaImageItem mediaImageItem3 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", + imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaImageItem3); + + final TransitionAlpha transition2And3 = + mVideoEditorHelper.createTAlpha("transition2And3", mediaVideoItem2, + mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN, + maskFilename, 30, false); + 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()); + assertTrue("Transition maskFile", + transition2And3.getMaskFilename().equals(maskFilename)); + assertEquals("Transition BlendingPercent", 30, + transition2And3.getBlendingPercent()); + assertFalse("Transition Invert", transition2And3.isInvert()); + + final MediaVideoItem mediaVideoItem4 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", + videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaVideoItem4.setExtractBoundaries(0, 18000); + mVideoEditor.addMediaItem(mediaVideoItem4); + + final TransitionAlpha transition3And4 = + mVideoEditorHelper.createTAlpha("transition3And4", mediaImageItem3, + mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR, maskFilename, + 50, false); + 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()); + assertTrue("Transition maskFile", + transition3And4.getMaskFilename().equals(maskFilename)); + assertEquals("Transition BlendingPercent", 50, + transition3And4.getBlendingPercent()); + assertFalse("Transition Invert", transition3And4.isInvert()); + + final MediaVideoItem mediaVideoItem5 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", + videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaVideoItem5); + + final TransitionAlpha transition4And5 = + mVideoEditorHelper.createTAlpha("transition4And5", mediaVideoItem4, + mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST, + maskFilename, 70, true); + 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()); + assertTrue("Transition maskFile", + transition4And5.getMaskFilename().equals(maskFilename)); + assertEquals("Transition BlendingPercent", 70, + transition4And5.getBlendingPercent()); + assertTrue("Transition Invert", transition4And5.isInvert()); + + final MediaVideoItem mediaVideoItem6 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", + videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaVideoItem6.setExtractBoundaries(0, 20000); + mVideoEditor.addMediaItem(mediaVideoItem6); + + try { + mVideoEditorHelper.createTAlpha("transition5And6", mediaVideoItem5, + mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, + INPUT_FILE_PATH + "imDummyFile.jpg", 70, + true); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("MaskFile is not exsisting", flagForException); + flagForException = false; + try { + mVideoEditorHelper.createTAlpha("transition5And6", null, null, 2000, + Transition.BEHAVIOR_MIDDLE_SLOW, maskFilename, 101, true); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Invalid Blending Percent", flagForException); + + flagForException = false; + try { + mVideoEditorHelper.createTAlpha("transitiond6", mediaVideoItem4, + mediaVideoItem5, 2000, Transition.BEHAVIOR_SPEED_UP - 1, + maskFilename, 30, false); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition FadeBlack with Invalid behavior", flagForException); + flagForException = false; + try { + mVideoEditorHelper.createTAlpha("transitiond6", mediaVideoItem4, + mediaVideoItem5, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, + maskFilename, 30, false); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition FadeBlack with Invalid behavior", flagForException); + } + + /** + * To test Frame Overlay for Media Video Item + */ + + // TODO : remove TC_API_041 + @SuppressWarnings("unused") + @LargeTest + public void testFrameOverlayVideoItem() throws Exception { + final String videoItemFilename1 = INPUT_FILE_PATH + + "H263_profile0_176x144_10fps_256kbps_0_25.3gp"; + final String overlayFile1 = INPUT_FILE_PATH + "IMG_176x144_Overlay1.png"; + final String overlayFile2 = INPUT_FILE_PATH + "IMG_176x144_Overlay2.png"; + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaVideoItem1); + + final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFile1, + 176, 144); + final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay( + mediaVideoItem1, "overlayId1", mBitmap1, 5000, 5000); + mediaVideoItem1.addOverlay(overlayFrame1); + + assertEquals("Overlay : Media Item", mediaVideoItem1, + overlayFrame1.getMediaItem()); + assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1")); + assertEquals("Overlay Bitmap", mBitmap1, overlayFrame1.getBitmap()); + assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime()); + assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); + + Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 176, 144); + overlayFrame1.setBitmap(upddateBmp); + assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap()); + upddateBmp.recycle(); + } + + /** + * To test Frame Overlay for Media Video Item : Set duration and Get + * Duration + */ + + // TODO : remove TC_API_042 + @LargeTest + public void testFrameOverlaySetAndGet() throws Exception { + final String videoItemFilename1 = INPUT_FILE_PATH + + "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4"; + final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; + boolean flagForException = false; + + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaVideoItem1); + + final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay( + mediaVideoItem1, "overlayId1", mBitmap, 5000, 5000); + mediaVideoItem1.addOverlay(overlayFrame1); + overlayFrame1.setDuration(5000); + + assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); + try { + overlayFrame1.setDuration(mediaVideoItem1.getDuration() + 10000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay Duration > MediaVideo Item Duration", + flagForException); + + assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); + flagForException = false; + + try { + overlayFrame1.setDuration(-1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay Duration = -1", flagForException); + } + + /** + * To test Frame Overlay for Media Video Item : Set duration and Get + * Duration + */ + + // TODO : remove TC_API_043 + @LargeTest + public void testFrameOverlayInvalidTime() throws Exception { + final String videoItemFilename1 = INPUT_FILE_PATH + + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; + final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; + boolean flagForException = false; + + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaVideoItem1); + + try { + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", + mBitmap, 400000000, 2000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay With Invalid Start Time", flagForException); + + flagForException = false; + try { + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId2", + mBitmap, -1, 2000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay With Invalid Start Time", flagForException); + + flagForException = false; + try { + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId3", + mBitmap, 2000, -1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay With Invalid Start Time", flagForException); + } + + /** + * To test Frame Overlay for Media Image Item + */ + // TODO : remove TC_API_045 + @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(); + } + + /** + * To test Frame Overlay for Media Image Item : Set duration and Get + * Duration + */ + + // TODO : remove TC_API_046 + @LargeTest + public void testFrameOverlaySetAndGetImage() throws Exception { + final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; + boolean flagForException = false; + + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, 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); + + overlayFrame1.setDuration(5000); + assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); + + try { + overlayFrame1.setDuration(mediaImageItem1.getDuration() + 10000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay Duration > Media Item Duration", flagForException); + assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); + + flagForException = false; + try { + overlayFrame1.setDuration(-1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay Duration = -1", flagForException); + } + + /** + * To test Frame Overlay for Media Image Item :Invalid StartTime and + * Duration + */ + + // TODO : remove TC_API_047 + @LargeTest + public void testFrameOverlayInvalidTimeImage() throws Exception { + final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; + boolean flagForException = false; + + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaImageItem1); + + try { + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", + mBitmap, 400000000, 2000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay With Invalid Start Time", flagForException); + + flagForException = false; + try { + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId2", + mBitmap, -1, 2000); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay With Invalid Start Time", flagForException); + + flagForException = false; + try { + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, + 640, 480); + mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId3", + mBitmap, 2000, -1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Overlay With Invalid Start Time", flagForException); + } + + /** + * To Test Frame Overlay Media Image Item :JPG File + */ + + // TODO : remove TC_API_048 + @LargeTest + public void testFrameOverlayJPGImage() throws Exception { + + final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; + boolean flagForException = false; + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + imageItemFilename, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); + mVideoEditor.addMediaItem(mediaImageItem1); + final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, + 480); + mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", + mBitmap, 5000, 5000); + } + + /** + * To test Video Editor API + * + * @throws Exception + */ + // TODO : remove TC_API_049 + @LargeTest + public void testVideoEditorAPI() throws Exception { + + final String videoItemFileName1 = INPUT_FILE_PATH + + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; + final String videoItemFileName2 = INPUT_FILE_PATH + + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; + final String videoItemFileName3 = INPUT_FILE_PATH + + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; + final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; + final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg"; + final String audioFilename1 = INPUT_FILE_PATH + + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; + final String audioFilename2 = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; + boolean flagForException = false; + TransitionCrossfade transition2And4; + + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFileName1, renderingMode); + mediaVideoItem1.setExtractBoundaries(0, 10000); + mVideoEditor.addMediaItem(mediaVideoItem1); + + final MediaVideoItem mediaVideoItem2 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", + videoItemFileName2, renderingMode); + mediaVideoItem2.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, + mediaVideoItem2.getDuration() / 2); + mVideoEditor.addMediaItem(mediaVideoItem2); + + final MediaVideoItem mediaVideoItem3 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", + videoItemFileName3, renderingMode); + mediaVideoItem3.setExtractBoundaries(mediaVideoItem3.getDuration() / 2, + mediaVideoItem3.getDuration()); + mVideoEditor.addMediaItem(mediaVideoItem3); + + final MediaImageItem mediaImageItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", + imageItemFileName1, 5000, renderingMode); + + final MediaImageItem mediaImageItem2 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", + imageItemFileName2, 5000, renderingMode); + + List<MediaItem> mediaList = mVideoEditor.getAllMediaItems(); + assertEquals("Media Item List Size", 3, mediaList.size()); + + mVideoEditor.insertMediaItem(mediaImageItem1, mediaVideoItem2.getId()); + mediaList = mVideoEditor.getAllMediaItems(); + assertEquals("Media Item List Size", 4, mediaList.size()); + assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0)); + assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1)); + assertEquals("Media item 4", mediaImageItem1, mediaList.get(2)); + assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3)); + + mVideoEditor.insertMediaItem(mediaImageItem2, mediaImageItem1.getId()); + mediaList = mVideoEditor.getAllMediaItems(); + assertEquals("Media Item List Size", 5, mediaList.size()); + assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0)); + assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1)); + assertEquals("Media item 4", mediaImageItem1, mediaList.get(2)); + assertEquals("Media item 5", mediaImageItem2, mediaList.get(3)); + assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4)); + + mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem2.getId()); + mediaList = mVideoEditor.getAllMediaItems(); + assertEquals("Media Item List Size", 5, mediaList.size()); + assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0)); + assertEquals("Media item 4", mediaImageItem1, mediaList.get(1)); + assertEquals("Media item 5", mediaImageItem2, mediaList.get(2)); + assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3)); + assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4)); + + assertEquals("Media Item 1", mediaVideoItem1, + mVideoEditor.getMediaItem(mediaVideoItem1.getId())); + + flagForException = false; + transition2And4 = null; + try{ + transition2And4 = mVideoEditorHelper.createTCrossFade( + "transition2And4", mediaVideoItem2, mediaImageItem1, 2000, + Transition.BEHAVIOR_MIDDLE_FAST); + mVideoEditor.addTransition(transition2And4); + } + catch (IllegalArgumentException e) { + flagForException = true; + } + assertFalse("Transition2and4 cannot be created", flagForException); + + + TransitionCrossfade transition1And3 = null; + flagForException = false; + try{ + transition1And3 = mVideoEditorHelper.createTCrossFade( + "transition1And3", mediaVideoItem1, mediaVideoItem2, 5000, + Transition.BEHAVIOR_MIDDLE_FAST); + mVideoEditor.addTransition(transition1And3); + }catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Transition1and3 cannot be created", flagForException); + + List<Transition> transitionList = mVideoEditor.getAllTransitions(); + assertEquals("Transition List", 1, transitionList.size()); + + assertEquals("Transition 2", transition2And4, + mVideoEditor.getTransition(transition2And4.getId())); + + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFilename1); + mVideoEditor.addAudioTrack(audioTrack); + + List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks(); + assertEquals("Audio List", 1, audioList.size()); + + final AudioTrack audioTrack1 = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack1", audioFilename2); + flagForException = false; + try { + mVideoEditor.addAudioTrack(audioTrack1); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Audio Track support is 1 ", flagForException); + + flagForException = false; + try { + mVideoEditor.insertAudioTrack(audioTrack1,"audioTrack"); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Audio Track supports is 1 ", flagForException); + + assertEquals("Removing AudioTrack", audioTrack, + mVideoEditor.removeAudioTrack(audioTrack.getId())); + + assertEquals("Removing transition", transition2And4, + mVideoEditor.removeTransition(transition2And4.getId())); + + assertEquals("Removing Media Item", mediaVideoItem2, + mVideoEditor.removeMediaItem(mediaVideoItem2.getId())); + + mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_16_9); + assertEquals("Check Aspect Ratio", MediaProperties.ASPECT_RATIO_16_9, + mVideoEditor.getAspectRatio()); + + long storyBoardDuration = mediaVideoItem1.getTimelineDuration() + + mediaVideoItem3.getTimelineDuration() + + mediaImageItem1.getDuration() + + mediaImageItem2.getDuration(); + assertEquals("Story Board Duration", storyBoardDuration, + mVideoEditor.getDuration()); + } + + /** + * To add Audio Track Greater than MediaItem Duration + * + * @throws Exception + */ + // TODO : remove TC_API_050 + @LargeTest + public void testVideoLessThanAudio() throws Exception { + final String videoItemFileName1 = INPUT_FILE_PATH + + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; + final String audioTrackFilename = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; + + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFileName1, renderingMode); + mVideoEditor.addMediaItem(mediaVideoItem1); + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrackId", audioTrackFilename); + mVideoEditor.addAudioTrack(audioTrack); + assertEquals("Storyboard = mediaItem Duration", + mediaVideoItem1.getDuration(), mVideoEditor.getDuration()); + assertTrue("Audio Duration > mediaItem Duration", + (audioTrack.getDuration() > mediaVideoItem1.getDuration() ? + true : false)); + } + + /** + * To test Video Editor API with 1080 P + * + * @throws Exception + */ + // TODO : remove TC_API_051 + @LargeTest + public void testVideoContentHD() throws Exception { + final String videoItemFileName1 = INPUT_FILE_PATH + + "H264_BP_1920x1080_30fps_1200Kbps_1_10.mp4"; + final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; + final MediaVideoItem mediaVideoItem1; + boolean flagForException = false; + try { + mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, + "m1", videoItemFileName1, renderingMode); + } catch (IllegalArgumentException e) { + flagForException = true; + } + assertTrue("VideoContent 1920x1080", flagForException); + } + + + /** + * To test: Remove audio track + * + * @throws Exception + */ + // TODO : remove TC_API_052 + @LargeTest + public void testRemoveAudioTrack() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + boolean flagForException = false; + + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack1", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + + assertEquals("Audio Track Item Duration", audioTrack.getDuration(), + audioTrack.getTimelineDuration()); + assertTrue("Audio Track ID", audioTrack.getId().equals("audioTrack1")); + assertNotNull("Remove Audio Track", + mVideoEditor.removeAudioTrack("audioTrack1")); + try{ + mVideoEditor.removeAudioTrack("audioTrack1"); + }catch (IllegalArgumentException e){ + flagForException = true; + } + assertTrue("Remove Audio Track not possible", flagForException); + } + + /** + * To test: Disable ducking + * + * @throws Exception + */ + // TODO : remove TC_API_053 + @LargeTest + public void testAudioDuckingDisable() throws Exception { + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + + audioTrack.disableDucking(); + assertFalse("Audio Track Ducking is Disabled", + audioTrack.isDuckingEnabled()); + } + + + // TODO : remove TC_API_054 + /** This test case is added with Test case ID TC_API_010 */ + + /** + * To test: Need a basic test case for the get value for TransitionAlpha + * ( ie. getBlendingPercent, getMaskFilename, isInvert) + * + * @throws Exception + */ + // TODO : remove TC_API_055 + @LargeTest + public void testTransitionAlphaBasic() throws Exception { + + final String videoItemFilename1 = INPUT_FILE_PATH + + "H264_BP_640x480_30fps_256kbps_1_17.mp4"; + final String maskFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; + boolean flagForException = false; + + final MediaVideoItem mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaVideoItem1.setExtractBoundaries(0, 15000); + + final MediaImageItem mediaImageItem = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, + 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaImageItem.setDuration(15000); + + mVideoEditor.addMediaItem(mediaVideoItem1); + mVideoEditor.addMediaItem(mediaImageItem); + final TransitionAlpha transition1And2 = + mVideoEditorHelper.createTAlpha("transition1And2", mediaVideoItem1, + mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, + maskFilename, 10, false); + mVideoEditor.addTransition(transition1And2); + assertTrue("Transition maskFile", + transition1And2.getMaskFilename().equals(maskFilename)); + assertEquals("Transition BlendingPercent", 10, + transition1And2.getBlendingPercent()); + assertFalse("Transition Invert", transition1And2.isInvert()); + } + + /** + * To test: NULL arguments to the Video Editor APIs + * + * @throws Exception + */ + // TODO : remove TC_API_056 + @LargeTest + public void testNullAPIs() throws Exception { + + final String videoItemFilename1 = INPUT_FILE_PATH + + "H264_BP_640x480_30fps_256kbps_1_17.mp4"; + final String maskFilename = INPUT_FILE_PATH + + "IMG_640x480_Overlay1.png"; + final String audioFileName = INPUT_FILE_PATH + + "AACLC_48KHz_256Kbps_s_1_17.3gp"; + boolean flagForException = false; + + try { + mVideoEditor.addAudioTrack(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Video Editor with null Audio Track", flagForException); + flagForException = false; + try { + mVideoEditor.addMediaItem(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Video Editor with NULL Image Item ", flagForException); + flagForException = false; + try { + mVideoEditor.addMediaItem(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Video Editor with NULL Video Item ", flagForException); + + MediaVideoItem mediaVideoItem1 = null; + try { + mediaVideoItem1 = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", + videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); + } catch (IllegalArgumentException e) { + assertTrue("Cannot Create Video Item", false); + } + mediaVideoItem1.setExtractBoundaries(0, 15000); + mVideoEditor.addMediaItem(mediaVideoItem1); + flagForException = false; + try { + mediaVideoItem1.addEffect(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Video with null effect ", flagForException); + flagForException = false; + try { + mediaVideoItem1.addOverlay(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Video with null overlay ", flagForException); + + final MediaImageItem mediaImageItem = + mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, + 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); + mediaImageItem.setDuration(15000); + mVideoEditor.addMediaItem(mediaImageItem); + flagForException = false; + try { + mediaImageItem.addEffect(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Image with null effect ", flagForException); + flagForException = false; + try { + mediaImageItem.addOverlay(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Image with null overlay ", flagForException); + + final AudioTrack audioTrack = mVideoEditorHelper.createAudio( + mVideoEditor, "audioTrack", audioFileName); + mVideoEditor.addAudioTrack(audioTrack); + + flagForException = false; + try { + mVideoEditor.addTransition(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Added null transition ", flagForException); + + flagForException = false; + try { + mVideoEditor.addTransition(null); + } catch(IllegalArgumentException e) { + flagForException = true; + } + assertTrue("Added null transition ", flagForException); + + } +} |