Search in sources :

Example 51 with AppBundleBuilder

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

the class AppBundleTest method hasSharedUserId_specifiedInFeatureModule_returnsFalse.

@Test
public void hasSharedUserId_specifiedInFeatureModule_returnsFalse() {
    AppBundle appBundle = new AppBundleBuilder().addModule("base", baseModule -> baseModule.setManifest(androidManifest(PACKAGE_NAME))).addModule("feature1", featureModule -> featureModule.setManifest(androidManifestForFeature(PACKAGE_NAME, withSharedUserId("shared_user_id")))).build();
    assertThat(appBundle.hasSharedUserId()).isFalse();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 52 with AppBundleBuilder

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

the class AppBundleTest method getPackageName_assetOnly.

@Test
public void getPackageName_assetOnly() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().setBundleConfig(BundleConfig.newBuilder().setType(BundleType.ASSET_ONLY).build()).addModule("asset1", baseModule -> baseModule.setManifest(ASSET_MODULE_MANIFEST)).build();
    assertThat(appBundle.getPackageName()).isEqualTo(PACKAGE_NAME);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 53 with AppBundleBuilder

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

the class AppBundleTest method isAssetOnly.

@Test
public void isAssetOnly() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().setBundleConfig(BundleConfig.newBuilder().setType(BundleType.ASSET_ONLY).build()).addModule("asset1", baseModule -> baseModule.setManifest(ASSET_MODULE_MANIFEST)).build();
    assertThat(appBundle.isAssetOnly()).isTrue();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 54 with AppBundleBuilder

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

the class AppBundleTest method storeArchiveEnabled_true.

@Test
public void storeArchiveEnabled_true() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().setBundleConfig(BundleConfigBuilder.create().setStoreArchive(true).build()).addModule("base", builder -> builder.setManifest(MANIFEST)).build();
    assertThat(appBundle.storeArchiveEnabled()).isTrue();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Example 55 with AppBundleBuilder

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

the class AppBundleTest method baseAndAssetModule_fromModules_areSeparated.

@Test
public void baseAndAssetModule_fromModules_areSeparated() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().addModule("base", baseModule -> baseModule.setManifest(MANIFEST).addFile("dex/classes.dex", DUMMY_CONTENT)).addModule("some_asset_module", module -> module.setManifest(ASSET_MODULE_MANIFEST).addFile("assets/img1.png", DUMMY_CONTENT)).build();
    assertThat(appBundle.getFeatureModules().keySet()).containsExactly(BundleModuleName.create("base"));
    assertThat(appBundle.getAssetModules().keySet()).containsExactly(BundleModuleName.create("some_asset_module"));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BundleType(com.android.bundle.Config.BundleConfig.BundleType) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) RunWith(org.junit.runner.RunWith) ZipBuilder(com.android.tools.build.bundletool.io.ZipBuilder) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ByteSource(com.google.common.io.ByteSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) Path(java.nio.file.Path) Before(org.junit.Before) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) ManifestProtoUtils.withSharedUserId(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSharedUserId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Rule(org.junit.Rule) XmlNode(com.android.aapt.Resources.XmlNode) BundleConfig(com.android.bundle.Config.BundleConfig) Optional(java.util.Optional) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TemporaryFolder(org.junit.rules.TemporaryFolder) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) Test(org.junit.Test)

Aggregations

AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)155 Test (org.junit.Test)153 AppBundle (com.android.tools.build.bundletool.model.AppBundle)134 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)123 Truth.assertThat (com.google.common.truth.Truth.assertThat)123 RunWith (org.junit.runner.RunWith)123 Path (java.nio.file.Path)113 ZipFile (java.util.zip.ZipFile)113 Before (org.junit.Before)113 Rule (org.junit.Rule)113 TemporaryFolder (org.junit.rules.TemporaryFolder)113 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)112 AppBundleSerializer (com.android.tools.build.bundletool.io.AppBundleSerializer)105 ImmutableList (com.google.common.collect.ImmutableList)102 BuildApksResult (com.android.bundle.Commands.BuildApksResult)101 Variant (com.android.bundle.Commands.Variant)94 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)91 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)88 ApkDescription (com.android.bundle.Commands.ApkDescription)87 BundleConfig (com.android.bundle.Config.BundleConfig)87