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
17package com.android.mediaframeworktest;
18
19import android.test.InstrumentationTestRunner;
20import android.test.InstrumentationTestSuite;
21import com.android.mediaframeworktest.unit.*;
22
23import 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
42public 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        return suite;
52    }
53
54    @Override
55    public ClassLoader getLoader() {
56        return MediaFrameworkUnitTestRunner.class.getClassLoader();
57    }
58
59    // Running all unit tests checking the state machine may be time-consuming.
60    private void addMediaMetadataRetrieverStateUnitTests(TestSuite suite) {
61        suite.addTestSuite(MediaMetadataRetrieverTest.class);
62    }
63
64    // Running all unit tests checking the state machine may be time-consuming.
65    private void addMediaRecorderStateUnitTests(TestSuite suite) {
66        suite.addTestSuite(MediaRecorderPrepareStateUnitTest.class);
67        suite.addTestSuite(MediaRecorderResetStateUnitTest.class);
68        suite.addTestSuite(MediaRecorderSetAudioEncoderStateUnitTest.class);
69        suite.addTestSuite(MediaRecorderSetAudioSourceStateUnitTest.class);
70        suite.addTestSuite(MediaRecorderSetOutputFileStateUnitTest.class);
71        suite.addTestSuite(MediaRecorderSetOutputFormatStateUnitTest.class);
72        suite.addTestSuite(MediaRecorderStartStateUnitTest.class);
73        suite.addTestSuite(MediaRecorderStopStateUnitTest.class);
74    }
75
76    // Running all unit tests checking the state machine may be time-consuming.
77    private void addMediaPlayerStateUnitTests(TestSuite suite) {
78        suite.addTestSuite(MediaPlayerGetDurationStateUnitTest.class);
79        suite.addTestSuite(MediaPlayerSeekToStateUnitTest.class);
80        suite.addTestSuite(MediaPlayerGetCurrentPositionStateUnitTest.class);
81        suite.addTestSuite(MediaPlayerGetVideoWidthStateUnitTest.class);
82        suite.addTestSuite(MediaPlayerGetVideoHeightStateUnitTest.class);
83        suite.addTestSuite(MediaPlayerIsPlayingStateUnitTest.class);
84        suite.addTestSuite(MediaPlayerResetStateUnitTest.class);
85        suite.addTestSuite(MediaPlayerPauseStateUnitTest.class);
86        suite.addTestSuite(MediaPlayerStartStateUnitTest.class);
87        suite.addTestSuite(MediaPlayerStopStateUnitTest.class);
88        suite.addTestSuite(MediaPlayerSetLoopingStateUnitTest.class);
89        suite.addTestSuite(MediaPlayerSetAudioStreamTypeStateUnitTest.class);
90        suite.addTestSuite(MediaPlayerSetVolumeStateUnitTest.class);
91        suite.addTestSuite(MediaPlayerMetadataParserTest.class);
92    }
93
94    private void addMediaScannerUnitTests(TestSuite suite) {
95        suite.addTestSuite(MediaInserterTest.class);
96    }
97}
98