Search in sources :

Example 31 with BundleModule

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

the class AndroidManifestValidatorTest method withMaxSdkEqualToInstantSdk_ok.

@Test
public void withMaxSdkEqualToInstantSdk_ok() throws Exception {
    BundleModule module = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withInstant(true), withOnDemandAttribute(false), withFusingAttribute(false), withMaxSdkVersion(21))).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 32 with BundleModule

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

the class AndroidManifestValidatorTest method conditionalModuleNonRemovable_throws.

@Test
public void conditionalModuleNonRemovable_throws() throws Exception {
    ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).addFile("assets/textures#tcf_astc/level1.assets").setManifest(androidManifest("com.test")).build(), new BundleModuleBuilder("asset_module").addFile("assets/other_textures#tcf_astc/astc_file.assets").setManifest(androidManifestForAssetModule("com.test.app", withInstallTimeRemovableElement(false), withMinSdkVersion(24), withFeatureCondition("android.feature"))).build());
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateAllModules(bundleModules));
    assertThat(exception).hasMessageThat().contains("Conditional modules cannot be set to non-removable.");
}
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 33 with BundleModule

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

the class AndroidManifestValidatorTest method assetOnly_ok.

@Test
public void assetOnly_ok() throws Exception {
    BundleModule module = new BundleModuleBuilder(BASE_MODULE_NAME, BundleConfig.newBuilder().setType(BundleConfig.BundleType.ASSET_ONLY).build()).setManifest(androidManifestForAssetModule(PKG_NAME)).build();
    new AndroidManifestValidator().validateAllModules(ImmutableList.of(module));
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 34 with BundleModule

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

the class AndroidManifestValidatorTest method assetModule_noVersionCode_ok.

@Test
public void assetModule_noVersionCode_ok() throws Exception {
    ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest("com.test", withVersionCode(2))).build(), new BundleModuleBuilder("asset_module").setManifest(androidManifestForAssetModule("com.test.app")).build());
    new AndroidManifestValidator().validateAllModules(bundleModules);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 35 with BundleModule

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

the class AndroidManifestValidatorTest method assetModuleWithInstantAttributeAndInstantDeliveryElement_throws.

@Test
public void assetModuleWithInstantAttributeAndInstantDeliveryElement_throws() throws Exception {
    BundleModule featureModule = new BundleModuleBuilder("asset_module").setManifest(androidManifestForAssetModule(PKG_NAME, withInstantOnDemandDelivery(), withInstant(true))).build();
    Throwable exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(featureModule));
    assertThat(exception).hasMessageThat().contains("The <dist:instant-delivery> element and dist:instant attribute cannot be used" + " together (module: 'asset_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