2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com
.android
.mediaframeworktest
.unit
;
19 import android
.media
.MediaPlayer
;
20 import android
.test
.AndroidTestCase
;
21 import android
.test
.suitebuilder
.annotation
.LargeTest
;
24 * Unit test class to test the set of valid and invalid states that
25 * MediaPlayer.setVolume() method can be called.
27 public class MediaPlayerSetVolumeStateUnitTest
extends AndroidTestCase
implements MediaPlayerMethodUnderTest
{
28 private MediaPlayerStateUnitTestTemplate mTestTemplate
= new MediaPlayerStateUnitTestTemplate();
31 * 1. It is valid to call setVolume() in the following states:
32 * {Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackComplted}.
33 * 2. It is invalid to call setVolume() in the following states:
36 * @param stateErrors the MediaPlayerStateErrors to check against.
38 public void checkStateErrors(MediaPlayerStateErrors stateErrors
) {
40 assertTrue(!stateErrors
.errorInStartedState
);
41 assertTrue(!stateErrors
.errorInStartedStateAfterPause
);
42 assertTrue(!stateErrors
.errorInPausedState
);
43 assertTrue(!stateErrors
.errorInPreparedState
);
44 assertTrue(!stateErrors
.errorInPreparedStateAfterStop
);
45 assertTrue(!stateErrors
.errorInPlaybackCompletedState
);
46 assertTrue(!stateErrors
.errorInIdleStateAfterReset
);
47 assertTrue(!stateErrors
.errorInInitializedState
);
48 assertTrue(!stateErrors
.errorInStoppedState
);
49 assertTrue(!stateErrors
.errorInIdleState
);
52 assertTrue(stateErrors
.errorInErrorState
);
55 public void invokeMethodUnderTest(MediaPlayer player
) {
56 player
.setVolume(0.5f
, 0.5f
);
60 public void testSetVolume() {
61 mTestTemplate
.runTestOnMethod(this);
65 public String
toString() {