Repository navigation
Expand file tree
/
Copy pathBundledResourceCopierTest.java
More file actions
73 lines (62 loc) Β· 2.65 KB
/
Copy pathBundledResourceCopierTest.java
File metadata and controls
73 lines (62 loc) Β· 2.65 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package cn.reactnative.modules.update;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import org.junit.Test;
public class BundledResourceCopierTest {
private static final HashSet<String> XXHDPI =
new HashSet<String>(Collections.singleton("xxhdpi"));
private static boolean canSubstitute(HashSet<String> installed, String... to) {
return BundledResourceCopier.canSubstituteDensityVariant(to, installed);
}
@Test
public void readsDensitiesFromConfigSplitNames() {
HashSet<String> densities = BundledResourceCopier.installedSplitDensities(
new ArrayList<String>(Arrays.asList(
"/data/app/x/base.apk",
"/data/app/x/split_config.arm64_v8a.apk",
"/data/app/x/split_config.zh.apk",
"/data/app/x/split_config.xxhdpi.apk",
"/data/app/x/split_feature.config.tvdpi.apk"
))
);
assertEquals(new HashSet<String>(Arrays.asList("xxhdpi", "tvdpi")), densities);
}
@Test
public void plainApkHasNoDensitySplits() {
assertTrue(BundledResourceCopier.installedSplitDensities(
new ArrayList<String>(Collections.singletonList("/data/app/x/base.apk"))
).isEmpty());
}
@Test
public void otherDensityOfASplitInstallCanBeSubstituted() {
assertTrue(canSubstitute(XXHDPI, "drawable-mdpi/a.png"));
assertTrue(canSubstitute(XXHDPI, "drawable-xhdpi/a.png", "drawable-hdpi/b.png"));
}
@Test
public void withoutADensitySplitEveryDensityShouldBeInstalled() {
assertFalse(canSubstitute(new HashSet<String>(), "drawable-mdpi/a.png"));
}
@Test
public void targetAtInstalledDensityIsDrift() {
assertFalse(canSubstitute(XXHDPI, "drawable-xxhdpi/a.png"));
assertFalse(canSubstitute(XXHDPI, "drawable-mdpi/a.png", "drawable-xxhdpi/b.png"));
}
@Test
public void targetsWithAnotherQualifierAreDrift() {
assertFalse(canSubstitute(XXHDPI, "drawable-night-hdpi/a.png"));
assertFalse(canSubstitute(XXHDPI, "drawable-hdpi-v21/a.png"));
assertFalse(canSubstitute(XXHDPI, "drawable-mdpi/a.png", "drawable-land-hdpi/b.png"));
}
@Test
public void targetsWithoutADensityAreDrift() {
assertFalse(canSubstitute(XXHDPI, "assets/a.png"));
assertFalse(canSubstitute(XXHDPI, "raw/a.bin"));
assertFalse(canSubstitute(XXHDPI, "drawable-nodpi/a.png"));
assertFalse(canSubstitute(XXHDPI, "drawable/a.png"));
}
}