Search in sources :

Example 36 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.

the class AndroidManifestValidatorTest method assetModuleWithOnDemandAndInstantAttributeSetToTrue_ok.

@Test
public void assetModuleWithOnDemandAndInstantAttributeSetToTrue_ok() throws Exception {
    BundleModule assetModule = new BundleModuleBuilder("assetmodule").setManifest(androidManifestForAssetModule(PKG_NAME, withOnDemandAttribute(true), withInstant(true))).build();
    new AndroidManifestValidator().validateModule(assetModule);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 37 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.

the class AndroidManifestValidatorTest method minSdkConditionGreaterEqualThanMinSdkVersion_ok.

@Test
public void minSdkConditionGreaterEqualThanMinSdkVersion_ok() throws Exception {
    BundleModule featureModule = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withFusingAttribute(true), withMinSdkCondition(24), withMinSdkVersion(19))).build();
    new AndroidManifestValidator().validateModule(featureModule);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 38 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.

the class AndroidManifestValidatorTest method assetModule_withApplication_throws.

@Test
public void assetModule_withApplication_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("asset_module").setManifest(androidManifestForAssetModule("com.test.app", withOnDemandDelivery(), withApplication())).build();
    Throwable exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Unexpected element declaration in manifest of asset pack 'asset_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 BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.

the class AndroidManifestValidatorTest method instantAssetModuleWithInstallTimeDelivery_throws.

@Test
public void instantAssetModuleWithInstallTimeDelivery_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("assetmodule").setManifest(androidManifestForAssetModule(PKG_NAME, withInstallTimeDelivery(), withInstantOnDemandDelivery())).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(exception).hasMessageThat().startsWith("Instant asset packs cannot have install-time delivery (module '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 40 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.

the class AndroidManifestValidatorTest method nonBase_withOnDemandDeliveryElement_ok.

@Test
public void nonBase_withOnDemandDeliveryElement_ok() throws Exception {
    BundleModule module = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest(PKG_NAME, withOnDemandDelivery(), 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

BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)349 Test (org.junit.Test)348 BundleModule (com.android.tools.build.bundletool.model.BundleModule)321 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)164 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)69 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)44 ResourceTable (com.android.aapt.Resources.ResourceTable)38 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)28 DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)19 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)16 Truth.assertThat (com.google.common.truth.Truth.assertThat)16 RunWith (org.junit.runner.RunWith)16 TestUtils.extractPaths (com.android.tools.build.bundletool.testing.TestUtils.extractPaths)15 ImmutableList (com.google.common.collect.ImmutableList)15 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)15 ProtoTruth.assertThat (com.google.common.truth.extensions.proto.ProtoTruth.assertThat)15 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)14 NativeLibraries (com.android.bundle.Files.NativeLibraries)13 HDPI (com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI)13 USER_PACKAGE_OFFSET (com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET)13