use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_gatherAllMetadataAndIntentFilters.
@Test
public void mergeChildrenMode_gatherAllMetadataAndIntentFilters() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("baseAction", "baseAction2"), /* metadata= */
ImmutableList.of("baseMeta"))), androidManifestForFeature("com.testapp.feature1", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature1Action"), /* metadata= */
ImmutableList.of("feature1Meta"))), androidManifestForFeature("com.testapp.feature2", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature2Action"), /* metadata= */
ImmutableList.of())));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature1Action", "feature2Action", "baseAction", "baseAction2"), /* metadata= */
ImmutableList.of("feature1Meta", "baseMeta"))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeFeatureActivitiesIntoBaseManifest.
@Test
@Theory
public void mergeFeatureActivitiesIntoBaseManifest(FusingAndroidManifestMerger.Mode mode) {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withCustomThemeActivity("activity1", BASE_THEME_REF_ID), withCustomThemeActivity("activity2", BASE_THEME_REF_ID), withCustomThemeActivity("activity3", BASE_THEME_REF_ID)), androidManifestForFeature("com.testapp.feature1", withCustomThemeActivity("activity1", FEATURE1_THEME_REF_ID)), androidManifestForFeature("com.testapp.feature2", withCustomThemeActivity("activity3", FEATURE2_THEME_REF_ID)));
AndroidManifest merged = createMerger(mode).merge(manifests);
Map<String, Integer> refIdByActivity = Maps.transformValues(merged.getActivitiesByName(), activity -> activity.getAndroidAttribute(THEME_RESOURCE_ID).get().getValueAsRefId());
assertThat(merged.getPackageName()).isEqualTo("com.testapp");
assertThat(refIdByActivity).containsExactly("activity1", FEATURE1_THEME_REF_ID, "activity2", BASE_THEME_REF_ID, "activity3", FEATURE2_THEME_REF_ID).inOrder();
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method duplicateManifest_throws.
@Test
public void duplicateManifest_throws() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = ImmutableSetMultimap.of(BASE_MODULE_NAME, AndroidManifest.create(androidManifest("com.testapp1")), BASE_MODULE_NAME, AndroidManifest.create(androidManifest("com.testapp2")));
CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> createMerger(Mode.REPLACE).merge(manifests));
assertThat(exception).hasMessageThat().isEqualTo("Expected exactly one base module manifest, but found 2.");
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class ModuleSplitsToShardMergerTest method manifests_valid_fuseFeatureApplicationElementsIntoBaseManifest.
@Test
public void manifests_valid_fuseFeatureApplicationElementsIntoBaseManifest() throws Exception {
AndroidManifest manifestBase = AndroidManifest.create(androidManifest("com.test.app1", withCustomThemeActivity("activity1", 1), withCustomThemeActivity("activity2", 2)));
AndroidManifest manifestFeat = AndroidManifest.create(androidManifest("com.test.app2", withCustomThemeActivity("activity1", 3), withMetadataValue("moduleMeta", "module"), withSplitNameActivityAlias("moduleActivityAlias", "module"), withSplitNameProvider("moduleProvider", "module"), withSplitNameReceiver("moduleReceiver", "module"), withSplitNameService("moduleService", "module")));
ModuleSplit split1 = createModuleSplitBuilder().setAndroidManifest(manifestBase).setModuleName(BundleModuleName.create("base")).build();
ModuleSplit split2 = createModuleSplitBuilder().setAndroidManifest(manifestFeat).setModuleName(BundleModuleName.create("module")).build();
ModuleSplit shard = splitsToShardMerger.mergeSingleShard(ImmutableList.of(split1, split2), createCache());
assertThat(shard.getAndroidManifest().getPackageName()).isEqualTo("com.test.app1");
assertThat(extractActivityThemeRefIds(shard.getAndroidManifest())).containsExactly("activity1", 3, "activity2", 2);
assertThat(extractApplicationElements(shard.getAndroidManifest())).containsExactly("activity1", ACTIVITY_ELEMENT_NAME, "activity2", ACTIVITY_ELEMENT_NAME, "moduleMeta", META_DATA_ELEMENT_NAME, "moduleActivityAlias", ACTIVITY_ALIAS_ELEMENT_NAME, "moduleProvider", PROVIDER_ELEMENT_NAME, "moduleReceiver", RECEIVER_ELEMENT_NAME, "moduleService", SERVICE_ELEMENT_NAME, "com.android.dynamic.apk.fused.modules", META_DATA_ELEMENT_NAME);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class ModuleSplitsToShardMergerTest method manifests_valid_mergeFeatureActivitiesIntoBaseManifest_versionBefore_1_8_0.
@Test
public void manifests_valid_mergeFeatureActivitiesIntoBaseManifest_versionBefore_1_8_0() throws Exception {
TestComponent.useTestModule(this, TestModule.builder().withBundletoolVersion("1.7.0").build());
AndroidManifest manifestBase = AndroidManifest.create(androidManifest("com.test.app1", withCustomThemeActivity("activity1", 1), withCustomThemeActivity("activity2", 2)));
AndroidManifest manifestFeat = AndroidManifest.create(androidManifest("com.test.app2", withCustomThemeActivity("activity1", 3), withMetadataValue("moduleMeta", "module"), withSplitNameActivityAlias("moduleActivityAlias", "module"), withSplitNameProvider("moduleProvider", "module"), withSplitNameReceiver("moduleReceived", "module"), withSplitNameService("moduleService", "module")));
ModuleSplit split1 = createModuleSplitBuilder().setAndroidManifest(manifestBase).setModuleName(BundleModuleName.create("base")).build();
ModuleSplit split2 = createModuleSplitBuilder().setAndroidManifest(manifestFeat).setModuleName(BundleModuleName.create("module")).build();
ModuleSplit shard = splitsToShardMerger.mergeSingleShard(ImmutableList.of(split1, split2), createCache());
assertThat(shard.getAndroidManifest().getPackageName()).isEqualTo("com.test.app1");
assertThat(extractActivityThemeRefIds(shard.getAndroidManifest())).containsExactly("activity1", 3, "activity2", 2);
assertThat(extractApplicationElements(shard.getAndroidManifest())).containsExactly("activity1", ACTIVITY_ELEMENT_NAME, "activity2", ACTIVITY_ELEMENT_NAME, "com.android.dynamic.apk.fused.modules", META_DATA_ELEMENT_NAME);
}
Aggregations