Loading core/tests/coretests/src/com/android/internal/content/res/OverlayConfigTest.java +38 −11 Original line number Diff line number Diff line Loading @@ -48,7 +48,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Presubmit @RunWith(AndroidJUnit4.class) Loading Loading @@ -102,6 +104,25 @@ public class OverlayConfigTest { return partitionOrder.toString(); } // configIndex should come from real time partition order cause partitions could get // reordered by /product/overlay/partition_order.xml private Map<String, Integer> createConfigIndexes(OverlayConfig overlayConfig, String... configPartitions) { Map<String, Integer> configIndexes = new HashMap<>(); for (int i = 0; i < configPartitions.length; i++) { configIndexes.put(configPartitions[i], -1); } String[] partitions = overlayConfig.getPartitionOrder().split(", "); int index = 0; for (int i = 0; i < partitions.length; i++) { if (configIndexes.containsKey(partitions[i])) { configIndexes.put(partitions[i], index++); } } return configIndexes; } @Test public void testImmutableAfterNonImmutableFails() throws IOException { mExpectedException.expect(IllegalStateException.class); Loading Loading @@ -292,11 +313,13 @@ public class OverlayConfigTest { mScannerRule.addOverlay(createFile("/system_ext/overlay/five.apk"), "five"); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", true, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", true, true, 2); assertConfig(overlayConfig, "four", true, true, 3); assertConfig(overlayConfig, "five", true, true, 4); Map<String, Integer> configIndexes = createConfigIndexes(overlayConfig, "vendor", "odm", "oem", "product", "system_ext"); assertConfig(overlayConfig, "one", true, true, configIndexes.get("vendor")); assertConfig(overlayConfig, "two", true, true, configIndexes.get("odm")); assertConfig(overlayConfig, "three", true, true, configIndexes.get("oem")); assertConfig(overlayConfig, "four", true, true, configIndexes.get("product")); assertConfig(overlayConfig, "five", true, true, configIndexes.get("system_ext")); } @Test Loading @@ -313,9 +336,11 @@ public class OverlayConfigTest { true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", false, true, 2); Map<String, Integer> configIndexes = createConfigIndexes(overlayConfig, "vendor", "odm", "product"); assertConfig(overlayConfig, "one", false, true, configIndexes.get("vendor")); assertConfig(overlayConfig, "two", true, true, configIndexes.get("odm")); assertConfig(overlayConfig, "three", false, true, configIndexes.get("product")); } @Test Loading @@ -327,9 +352,11 @@ public class OverlayConfigTest { true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); assertConfig(overlayConfig, "three", false, true, 2); Map<String, Integer> configIndexes = createConfigIndexes(overlayConfig, "vendor", "odm", "product"); assertConfig(overlayConfig, "one", false, true, configIndexes.get("vendor")); assertConfig(overlayConfig, "two", false, true, configIndexes.get("odm")); assertConfig(overlayConfig, "three", false, true, configIndexes.get("product")); } @Test Loading Loading
core/tests/coretests/src/com/android/internal/content/res/OverlayConfigTest.java +38 −11 Original line number Diff line number Diff line Loading @@ -48,7 +48,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Presubmit @RunWith(AndroidJUnit4.class) Loading Loading @@ -102,6 +104,25 @@ public class OverlayConfigTest { return partitionOrder.toString(); } // configIndex should come from real time partition order cause partitions could get // reordered by /product/overlay/partition_order.xml private Map<String, Integer> createConfigIndexes(OverlayConfig overlayConfig, String... configPartitions) { Map<String, Integer> configIndexes = new HashMap<>(); for (int i = 0; i < configPartitions.length; i++) { configIndexes.put(configPartitions[i], -1); } String[] partitions = overlayConfig.getPartitionOrder().split(", "); int index = 0; for (int i = 0; i < partitions.length; i++) { if (configIndexes.containsKey(partitions[i])) { configIndexes.put(partitions[i], index++); } } return configIndexes; } @Test public void testImmutableAfterNonImmutableFails() throws IOException { mExpectedException.expect(IllegalStateException.class); Loading Loading @@ -292,11 +313,13 @@ public class OverlayConfigTest { mScannerRule.addOverlay(createFile("/system_ext/overlay/five.apk"), "five"); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", true, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", true, true, 2); assertConfig(overlayConfig, "four", true, true, 3); assertConfig(overlayConfig, "five", true, true, 4); Map<String, Integer> configIndexes = createConfigIndexes(overlayConfig, "vendor", "odm", "oem", "product", "system_ext"); assertConfig(overlayConfig, "one", true, true, configIndexes.get("vendor")); assertConfig(overlayConfig, "two", true, true, configIndexes.get("odm")); assertConfig(overlayConfig, "three", true, true, configIndexes.get("oem")); assertConfig(overlayConfig, "four", true, true, configIndexes.get("product")); assertConfig(overlayConfig, "five", true, true, configIndexes.get("system_ext")); } @Test Loading @@ -313,9 +336,11 @@ public class OverlayConfigTest { true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", true, true, 1); assertConfig(overlayConfig, "three", false, true, 2); Map<String, Integer> configIndexes = createConfigIndexes(overlayConfig, "vendor", "odm", "product"); assertConfig(overlayConfig, "one", false, true, configIndexes.get("vendor")); assertConfig(overlayConfig, "two", true, true, configIndexes.get("odm")); assertConfig(overlayConfig, "three", false, true, configIndexes.get("product")); } @Test Loading @@ -327,9 +352,11 @@ public class OverlayConfigTest { true, 0); final OverlayConfig overlayConfig = createConfigImpl(); assertConfig(overlayConfig, "one", false, true, 0); assertConfig(overlayConfig, "two", false, true, 1); assertConfig(overlayConfig, "three", false, true, 2); Map<String, Integer> configIndexes = createConfigIndexes(overlayConfig, "vendor", "odm", "product"); assertConfig(overlayConfig, "one", false, true, configIndexes.get("vendor")); assertConfig(overlayConfig, "two", false, true, configIndexes.get("odm")); assertConfig(overlayConfig, "three", false, true, configIndexes.get("product")); } @Test Loading