blob: 134144d005b986b1dc1075409d448de8abdaa6b7 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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.unit;
18
19import android.media.MediaRecorder;
20import android.test.AndroidTestCase;
Yu Shan Emily Lau3e7b3c02009-03-24 22:20:13 -070021import android.test.suitebuilder.annotation.MediumTest;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.test.suitebuilder.annotation.Suppress;
23import java.io.IOException;
24
25/**
26 * Unit test class to test the set of valid and invalid states that
27 * MediaRecorder.prepare() method can be called.
28 */
29public class MediaRecorderPrepareStateUnitTest extends AndroidTestCase implements MediaRecorderMethodUnderTest {
30 private MediaRecorderStateUnitTestTemplate mTestTemplate = new MediaRecorderStateUnitTestTemplate();
31
32 /**
33 * 1. It is valid to call prepare() in the following states:
34 * {DataSourceConfigured}.
35 * 2. It is invalid to call prepare() in the following states:
36 * {Prepared, Initial, Initialized, Recording, Error}
37 *
38 * @param stateErrors the MediaRecorderStateErrors to check against.
39 */
40 public void checkStateErrors(MediaRecorderStateErrors stateErrors) {
41 // Valid states.
42 assertTrue(!stateErrors.errorInDataSourceConfiguredState);
43
44 // Invalid states.
45 assertTrue(stateErrors.errorInPreparedState);
46 assertTrue(stateErrors.errorInRecordingState);
47 assertTrue(stateErrors.errorInInitialState);
48 assertTrue(stateErrors.errorInInitialStateAfterReset);
49 assertTrue(stateErrors.errorInInitialStateAfterStop);
50 assertTrue(stateErrors.errorInInitializedState);
51 assertTrue(stateErrors.errorInErrorState);
52 }
53
54 public void invokeMethodUnderTest(MediaRecorder recorder) {
55 try {
56 recorder.prepare();
57 } catch (IOException exception) {
58 throw new RuntimeException();
59 }
60 }
61
Yu Shan Emily Lau3e7b3c02009-03-24 22:20:13 -070062 @MediumTest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 public void testPrepare() {
64 mTestTemplate.runTestOnMethod(this);
65 }
66
67 @Override
68 public String toString() {
69 return "prepare()";
70 }
71}