Search in sources :

Example 36 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.

the class AndroidManifestValidatorTest method withMultipleDistinctSplitIds_throws.

@Test
public void withMultipleDistinctSplitIds_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifestForFeature(PKG_NAME, withSplitId(FEATURE_MODULE_NAME), withSecondSplitId("modulesplitname2"))).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("attribute 'split' cannot be declared more than once");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 37 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.

the class AndroidManifestValidatorTest method assetModuleWithConditionalTargeting_throws.

@Test
public void assetModuleWithConditionalTargeting_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("assetmodule").setManifest(androidManifestForAssetModule(PKG_NAME, withFeatureCondition("camera"))).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Conditional targeting is not allowed in asset packs, but found in 'assetmodule'.");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 38 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.

the class AndroidManifestValidatorTest method base_withOnDemandAttributeSetToFalse_ok.

@Test
public void base_withOnDemandAttributeSetToFalse_ok() throws Exception {
    BundleModule module = new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withOnDemandAttribute(false))).build();
    new AndroidManifestValidator().validateModule(module);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 39 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.

the class AndroidManifestValidatorTest method withNegativeMinSdk_throws.

@Test
public void withNegativeMinSdk_throws() throws Exception {
    BundleModule module = baseModule(withMinSdkVersion(-1));
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(e).hasMessageThat().isEqualTo("minSdkVersion must be nonnegative, found: (-1).");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 40 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.

the class AndroidManifestValidatorTest method installTimeAndOnDemandDeliveryAndInstantAttributeSetToTrue_ok.

@Test
public void installTimeAndOnDemandDeliveryAndInstantAttributeSetToTrue_ok() throws Exception {
    // On-demand delivery element does not make a module on-demand if install-time element is
    // present.
    BundleModule module = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withInstallTimeDelivery(), withOnDemandDelivery(), withInstant(true), withFusingAttribute(true))).build();
    new AndroidManifestValidator().validateModule(module);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Aggregations

BundleModule (com.android.tools.build.bundletool.model.BundleModule)404 Test (org.junit.Test)370 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)321 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)158 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)112 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)42 ResourceTable (com.android.aapt.Resources.ResourceTable)40 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)29 ImmutableList (com.google.common.collect.ImmutableList)27 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)24 ImmutableSet (com.google.common.collect.ImmutableSet)22 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)21 DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)19 AppBundle (com.android.tools.build.bundletool.model.AppBundle)15 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)15 TestUtils.extractPaths (com.android.tools.build.bundletool.testing.TestUtils.extractPaths)15 Truth.assertThat (com.google.common.truth.Truth.assertThat)15 RunWith (org.junit.runner.RunWith)15 Assets (com.android.bundle.Files.Assets)14 VariantTargeting (com.android.bundle.Targeting.VariantTargeting)14