-
Notifications
You must be signed in to change notification settings - Fork 831
/
Copy pathCpuArchTest.java
executable file
·38 lines (29 loc) · 1.22 KB
/
CpuArchTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.github.hiteshsondhi88.libffmpeg;
import android.content.res.AssetManager;
import android.text.TextUtils;
import com.github.hiteshsondhi88.libffmpeg.utils.AssertionHelper;
import java.io.IOException;
import java.io.InputStream;
import static org.assertj.core.api.Assertions.assertThat;
public class CpuArchTest extends CommonInstrumentationTestCase {
public void testFFmpegAssetsWithSha1Sum() {
testFFmpegAsset(CpuArch.ARMv7, "armeabi-v7a/ffmpeg");
testFFmpegAsset(CpuArch.x86, "x86/ffmpeg");
}
private void testFFmpegAsset(CpuArch cpuArch, String assetsPath) {
AssetManager assetMgr = getInstrumentation().getContext().getResources().getAssets();
InputStream is = null;
try {
is = assetMgr.open(assetsPath);
String assetSha1Sum = FileUtils.SHA1(is);
assertThat(!TextUtils.isEmpty(cpuArch.getSha1())
&& !TextUtils.isEmpty(assetSha1Sum)
&& cpuArch.getSha1().equals(assetSha1Sum)).isTrue();
} catch (IOException e) {
Log.e(e);
AssertionHelper.assertError("error validating ffmpeg asset "+assetsPath);
} finally {
Util.close(is);
}
}
}