Android Steps to use AndroidTestCase
1. Create a new class to inherit AndroidTestCase
Copy the codeThe code is as follows:
public class TestAudio extends AndroidTestCase {
private AudioManager mAudioManager;
private boolean mUseFixedVolume;
private final static long TIME_TO_PLAY = 2000;
private final static int MP3_TO_PLAY = .testmp3;
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
();
}
public void testmp3(){
MediaPlayer mp = (mContext, MP3_TO_PLAY);
(STREAM_MUSIC);
(true);
();
try {
(20*1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
();
}
}
}
2. Modify the file
Add inside application
Copy the codeThe code is as follows:
<uses-library android:name="" />
Add the location of the application tag at the same level
Copy the codeThe code is as follows:
<instrumentation
android:name=""
android:label="test"
android:targetPackage="" />
The location of the two tags above is very important. I will be depressed only if I post the wrong location of the instrumentation.
specific:
Copy the codeThe code is as follows:
<manifest xmlns:androaa">/apk/res/android"
package=""
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="" />
</application>
<!-- Add position at the same level as the application tag -->
<instrumentation
android:name=""
android:label="test"
android:targetPackage="" />
</manifest>