1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.mediaframeworktest; 18 19 import android.test.InstrumentationTestRunner; 20 import android.test.InstrumentationTestSuite; 21 import com.android.mediaframeworktest.unit.*; 22 23 import junit.framework.TestSuite; 24 25 /** 26 * Instrumentation Test Runner for all media framework unit tests. 27 * 28 * Make sure that MediaFrameworkUnitTestRunner has been added to 29 * AndroidManifest.xml file, and then "make -j4 mediaframeworktest; adb sync" 30 * to build and upload mediaframeworktest to the phone or emulator. 31 * 32 * Example on running all unit tests for a single class: 33 * adb shell am instrument -e class \ 34 * com.android.mediaframeworktest.unit.MediaMetadataRetrieverUnitTest \ 35 * -w com.android.mediaframeworktest/.MediaFrameworkUnitTestRunner 36 * 37 * Example on running all unit tests for the media framework: 38 * adb shell am instrument \ 39 * -w com.android.mediaframeworktest/.MediaFrameworkUnitTestRunner 40 */ 41 42 public class MediaFrameworkUnitTestRunner extends InstrumentationTestRunner { 43 44 @Override 45 public TestSuite getAllTests() { 46 TestSuite suite = new InstrumentationTestSuite(this); 47 addMediaMetadataRetrieverStateUnitTests(suite); 48 addMediaRecorderStateUnitTests(suite); 49 addMediaPlayerStateUnitTests(suite); 50 addMediaScannerUnitTests(suite); 51 addCameraUnitTests(suite); 52 addImageReaderTests(suite); 53 addExifInterfaceTests(suite); 54 return suite; 55 } 56 57 @Override 58 public ClassLoader getLoader() { 59 return MediaFrameworkUnitTestRunner.class.getClassLoader(); 60 } 61 62 private void addCameraUnitTests(TestSuite suite) { 63 suite.addTestSuite(CameraUtilsUncheckedThrowTest.class); 64 suite.addTestSuite(CameraUtilsTypeReferenceTest.class); 65 suite.addTestSuite(CameraMetadataTest.class); 66 } 67 68 private void addImageReaderTests(TestSuite suite) { 69 suite.addTestSuite(ImageReaderTest.class); 70 } 71 72 // Running all unit tests checking the state machine may be time-consuming. 73 private void addMediaMetadataRetrieverStateUnitTests(TestSuite suite) { 74 suite.addTestSuite(MediaMetadataRetrieverTest.class); 75 } 76 77 // Running all unit tests checking the state machine may be time-consuming. 78 private void addMediaRecorderStateUnitTests(TestSuite suite) { 79 suite.addTestSuite(MediaRecorderPrepareStateUnitTest.class); 80 suite.addTestSuite(MediaRecorderResetStateUnitTest.class); 81 suite.addTestSuite(MediaRecorderSetAudioEncoderStateUnitTest.class); 82 suite.addTestSuite(MediaRecorderSetAudioSourceStateUnitTest.class); 83 suite.addTestSuite(MediaRecorderSetOutputFileStateUnitTest.class); 84 suite.addTestSuite(MediaRecorderSetOutputFormatStateUnitTest.class); 85 suite.addTestSuite(MediaRecorderStartStateUnitTest.class); 86 suite.addTestSuite(MediaRecorderStopStateUnitTest.class); 87 } 88 89 // Running all unit tests checking the state machine may be time-consuming. 90 private void addMediaPlayerStateUnitTests(TestSuite suite) { 91 suite.addTestSuite(MediaPlayerGetDurationStateUnitTest.class); 92 suite.addTestSuite(MediaPlayerSeekToStateUnitTest.class); 93 suite.addTestSuite(MediaPlayerGetCurrentPositionStateUnitTest.class); 94 suite.addTestSuite(MediaPlayerGetVideoWidthStateUnitTest.class); 95 suite.addTestSuite(MediaPlayerGetVideoHeightStateUnitTest.class); 96 suite.addTestSuite(MediaPlayerIsPlayingStateUnitTest.class); 97 suite.addTestSuite(MediaPlayerResetStateUnitTest.class); 98 suite.addTestSuite(MediaPlayerPauseStateUnitTest.class); 99 suite.addTestSuite(MediaPlayerStartStateUnitTest.class); 100 suite.addTestSuite(MediaPlayerStopStateUnitTest.class); 101 suite.addTestSuite(MediaPlayerSetLoopingStateUnitTest.class); 102 suite.addTestSuite(MediaPlayerSetAudioStreamTypeStateUnitTest.class); 103 suite.addTestSuite(MediaPlayerSetVolumeStateUnitTest.class); 104 suite.addTestSuite(MediaPlayerMetadataParserTest.class); 105 } 106 107 private void addMediaScannerUnitTests(TestSuite suite) { 108 suite.addTestSuite(MediaInserterTest.class); 109 } 110 111 private void addExifInterfaceTests(TestSuite suite) { 112 suite.addTestSuite(ExifInterfaceTest.class); 113 } 114 } 115